|
-
April 25th, 2001, 04:02 PM
#1
Opening a file with its default application
Hey,
I need to open a file in code using the windows default application method...
Like doulble clicking on the file in explorer and having the application start and opening the file automaticaly.
thanks,
Rick
[email protected]
www.i4i.com
-
April 25th, 2001, 04:02 PM
#2
Opening a file with its default application
Hey,
I need to open a file in code using the windows default application method...
Like doulble clicking on the file in explorer and having the application start and opening the file automaticaly.
thanks,
Rick
[email protected]
www.i4i.com
-
April 25th, 2001, 05:51 PM
#3
Re: Opening a file with its default application
Use The ShellExecute API. It will open the file with whatever program is associated with it
option Explicit
private 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
private Sub Command1_Click()
Dim retval as Long
'//Open HTML File In Default Browser
retval = ShellExecute(Form1.hwnd, "open", "C:\Test.htm", "", "c:\", 1)
End Sub
private Sub Command2_Click()
Dim retval as Long
'//Open Text File
retval = ShellExecute(Form1.hwnd, "open", "C:\Test.txt", "", "c:\", 1)
End Sub
private Sub Command3_Click()
Dim retval as Long
'//Open Word Document
retval = ShellExecute(Form1.hwnd, "open", "C:\Test.doc", "", "c:\", 1)
End Sub
Kris
Software Engineer
Phoenix,AZ
Kris
Software Engineer
Phoenix, AZ USA
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
|