|
-
Jun 7th, 2006, 05:38 AM
#1
Thread Starter
New Member
Opening Files Through Their Default Application...
Hi, I have a program with of files that I want to be able to access. Most of these are executable files so I have no problems in accessing them with the Simple shell filename command. However, I've just learned that this doesn't work with the zip files in the list. How could I make my application open a zip file with the computers default application? So it I had winzip on my computer for example, clicking on the zip in my application would bring up winzip with the file as a parameter. Thanks for any help. Regards,
Rich.
-
Jun 7th, 2006, 05:42 AM
#2
Re: Opening Files Through Their Default Application...
Use ShellExecute API. This API will open the file in the associated application.
VB Code:
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
Const SW_SHOWNORMAL = 1
Private Sub Form_Load()
ShellExecute Me.hwnd, vbNullString, "C:\Test.doc", vbNullString, "C:\", SW_SHOWNORMAL
End Sub
Use [code] source code here[/code] tags when you post source code.
My Articles
-
Jun 7th, 2006, 05:43 AM
#3
Re: Opening Files Through Their Default Application...
but a zip file will be opened in explorer rather than by the default UnZipping app.
-
Jun 7th, 2006, 05:55 AM
#4
Re: Opening Files Through Their Default Application...
 Originally Posted by bushmobile
but a zip file will be opened in explorer rather than by the default UnZipping app.
I am afraid no.
It will open the associated WinZip (or some other zipping utility) application.
Use [code] source code here[/code] tags when you post source code.
My Articles
-
Jun 7th, 2006, 06:05 AM
#5
Re: Opening Files Through Their Default Application...
If the user has a zipping utility set up as the default association then maybe.
but in XP the built in Extraction Wizard is not the default option - opening in explorer is.
-
Jun 7th, 2006, 06:10 AM
#6
Re: Opening Files Through Their Default Application...
 Originally Posted by bushmobile
If the user has a zipping utility set up as the default association then maybe.
Correct 
 Originally Posted by bushmobile
but in XP the built in Extraction Wizard is not the default option - opening in explorer is.
I have Winzip installed so I tried it with that. Didn't try it without Winzip on XP.
Use [code] source code here[/code] tags when you post source code.
My Articles
-
Jun 7th, 2006, 06:17 AM
#7
Re: Opening Files Through Their Default Application...
you could always check if computer is running XP and if they are then use the built-in extractor, and on other systems use shellexecute.
-
Jun 7th, 2006, 09:17 AM
#8
Thread Starter
New Member
Re: Opening Files Through Their Default Application...
Thanks a lot guys, this code is excellent and is just what I was looking for!
-
Sep 30th, 2006, 02:33 PM
#9
-
Sep 30th, 2006, 04:24 PM
#10
Re: Opening Files Through Their Default Application...
I don't believe so, unless you send an enter key to get rid of the prompt yourself. It's a security risk of sorts to allow you to add .reg files (which could be maliciously edited) to the registry without the permission of the user. When it's hard coded in, it's usually safer, or as safe as it could be, as long as the program was built with good intentions!
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
|