Link to home
Start Free TrialLog in
Avatar of mcdonald_g
mcdonald_gFlag for United States of America

asked on

Code to open file automatically by association

I am looking for the code to open an associated file automatically. For example, I have created a VB application which opens and read files with the extension .PAG

When a user double-clicks on a file with the extension of .PAG in Windows Explorer, I want the VB application to open that particular file after starting.
Avatar of mflam
mflam

If its a new extention, simply double click it in windows explorer.
windows asks what to use.
browse to your app, check the "always use this program" and OK.

If you want to do this programattically, use the api viewer to add registry funcs.
Go HKey_CLASSES_Root and find your key(s), simply emulate this.

Moshe.
Avatar of mcdonald_g

ASKER

The code I am looking for is strictly VB syntax. I already have the association set in Windows Explorer.

I need the VB code to open the file that was double-clicked in Explorer.

Right now when I double-click on a filename with an extension of .PAG, my VB app launches but it doesn't open the file. I need to plug in code to open the file after the app starts.
ASKER CERTIFIED SOLUTION
Avatar of dhnkley
dhnkley

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
When the program starts, check the value of the Command function.  It should be the filename if your program was started from clicking on an associated file.
Thanks a lot! It worked.