Link to home
Start Free TrialLog in
Avatar of wsanchez
wsanchez

asked on

Associating file types with a .exe

How do you associate a filetype to a certain .exe file made using vb and a certain icon?  What do I have to add to the setup program?
Avatar of yowkee
yowkee

wsanchez,

  Basically to associate a extension with your application, you must have appropriate information in the Registry. For example, your application name test.exe and stay in folder C:\temp, the extension to associate is .aaa. Then, in your registry, these key must existed:
(HKCR = HKEY_CLASSES_ROOT)

[HKCR\.aaa]
@Defaule="aaafile"

[HKCR\aaafile\shell\open\command]
@Default="C:\temp\test.exe %1"

' And the default icon for the file with .aaa
[HKCR\aaafile\DefaultIcon]
@Default="C:\temp\test.exe,1"   (this mean first icon contain in                                  test.exe)


Use regedit.exe to open the registry and looking for HKCR\.htm, HKCR\htmlfiles and you will know how to do it.

For setting this info, you must modify your setup wizard program, to add stuff for insert info into registry in the startup of setup.

For reference, look for MS KB Q185453. I think the PAQ also got some similiar question.

Regards
wsanchez,

  Basically to associate a extension with your application, you must have appropriate information in the Registry. For example, your application name test.exe and stay in folder C:\temp, the extension to associate is .aaa. Then, in your registry, these key must existed:
(HKCR = HKEY_CLASSES_ROOT)

[HKCR\.aaa]
@Defaule="aaafile"

[HKCR\aaafile\shell\open\command]
@Default="C:\temp\test.exe %1"

' And the default icon for the file with .aaa
[HKCR\aaafile\DefaultIcon]
@Default="C:\temp\test.exe,1"   (this mean first icon contain in                                  test.exe)


Use regedit.exe to open the registry and looking for HKCR\.htm, HKCR\htmlfiles and you will know how to do it.

For setting this info, you must modify your setup wizard program, to add stuff for insert info into registry in the startup of setup.

For reference, look for MS KB Q185453. I think the PAQ also got some similiar question.

Regards
ASKER CERTIFIED SOLUTION
Avatar of Dr. Kamal Mehdi
Dr. Kamal Mehdi
Flag of Greece image

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
Avatar of wsanchez

ASKER

To kamall.  What do I write in the INI file? Sorry for asking but I'm quite new at this.  Also, what if the person who installs the software gives a different installation path during installation?  How would I reflect the path in the registry?
wsanchez,
Sorry for the delay in reponding, but I didn't get e-mail notification of your comment. I saw your other question 'To kamall...' which led me here.
So, the solution to your question is very simple.
You can just create an empty INI file (or write anything you like) when your program runs for the first time, and put it in the application's directory. You can simply get the application directory using the App.Path
Now when your program runs, you simply check whether your INI file exists. If not, then it is the first time, otherwise it is not.
This will not cause you any problems if the user installs your application in any other directory name.
Regards
Thanks Kamall.
You are welcome wsanchez.
For any more questions, leave me a comment.
Best regards.