2006/02/16

File extension association under windows

The windows registry is always a mistery to me. Microsoft made everything as complicated as possible, you can see how complicated it is here if you are not in a hurry.

Basically, InstallShield has [Registry Entries] function in the [Resources] tag.
1) Add a new entry in the [Registry Entries], normally the name of the entry will be "Registry Set-1".
2) Under [HKEY_CLASSES_ROOT], add a new key.
3) Type the key name as .ext\shell\open\command, where the .ext is the name of your extension.
4) Automatically, under this key, there will be a String Value with default empty value, modify the string value to <targetdir>\YourApp.exe, if you'd like the application to open that file, then add a %1 as a command line parameter. So basically, you would type:
<targetdir>\YourApp.exe %1

However, the story is not over yet. If the system is not rebooted, then this information is not updated to the windows system. So in the [Scripts], you need to add the following:
#define SHCNE_ASSOCCHANGED 0x08000000
#define SHCNF_IDLIST 0x0000

prototype Shell32.SHChangeNotify(LONG, LONG, POINTER, POINTER);

// ...and later...

SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL);

Well, it's not guaranteed to work. For example, the installshield version coming with VC++ will not accept this dll function prototype, only professional version will work.


1 comment:

free online xrated sex porn stories said...
This comment has been removed by a blog administrator.