|
-
May 31st, 2000, 11:07 PM
#1
Thread Starter
Member
Hi there
1) How do I open a file in its default viewer/editor?????
2) Ive got a filelist box, when the user clicks the a file I want a picture box on the same form to show the default icon for the program??
Can anyone help with these questions?
Thanks in advance!!
-
May 31st, 2000, 11:18 PM
#2
Addicted Member
Answer to Question 1
Well, here is the code I usually use for default programs...
Code:
' Usually in a module...
Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Public Const SW_SHOWNORMAL = 1
' A URL to invoke browser
lResult = ShellExecute(0&, vbNullString, "http://www.vb-world.net/", vbNullString, "C:\", SW_SHOWNORMAL)
' A URL to invoke mail client
lResult = ShellExecute(0&, vbNullString, "mailto:[email protected]", vbNullString, "C:\", SW_SHOWNORMAL)
' Open Notepad, EditPad, etc.
lResult = ShellExecute(0&, vbNullString, "c:\windows\setup.txt", vbNullString, "C:\", SW_SHOWNORMAL)
I hope this helps!
-
May 31st, 2000, 11:19 PM
#3
_______
Hopefully this answers one part.
'open a file with associated app can be done this way [using API]
'open a file with it's associated application
'this example opens addin.txt with notepad
'put this in a bas module
'
Public Declare Function ShellEx Lib "shell32.dll" Alias _
"ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, ByVal lpParameters As Any, _
ByVal lpDirectory As Any, ByVal nShowCmd As Long) As Long
'
Sub ShellDef(strFileName)
x = ShellEx(Form1.hwnd, "open", strFileName, "", "", 1)
End Sub
' >>> code for event on form <<<
'
Dim strYourFileVariable$
strYourFileVariable = "c:\your folder\yourfile.ext"
ShellDef strYourFileVariable
'=====================================
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|