PDA

View Full Version : Create file association


Adam
04-28-2008, 11:16 AM
Question:
Can I create a file association using actions in Setup Factory 7.0?

Answer:
Yes you can create a file association in the following IndigoRose titles:

And here is how:

In order to set up a file association we will need to use two set Registry value actions and an optional third set Registry value action.

Example

This example creates a file association between the file extension *.KQX and the program %AppFolder%\\MyProgram.exe.

The first Modify Registry action will link the *.KQX file extension with "KQXEditor" which is another registry key:

Registry Action: Set Value
Main Key: HKEY_CLASSES_ROOT
Sub Key: .KQX
Value:
Data: KQXEditor
Type: REG_SZ

Example:
Registry.SetValue(HKEY_CLASSES_ROOT, ".KQX", "", "KQXEditor", REG_SZ);

The "KQXEditor" registry key will tell the operating system what to do with files that have the *.KQX extension. We will tell the operating system to open all files, with the *.KQX extension, with %AppFolder%\\MyProgram.exe. The next Modify Registry action will create the KQXEditor registry key:

Registry Action: Set Value
Main Key: HKEY_CLASSES_ROOT
Sub Key: KQXEditor\\shell\\open\\command
Value:
Data: %AppFolder%\\MyProgram.exe "%1"
Type: REG_SZ

Example:
Registry.SetValue(HKEY_CLASSES_ROOT, "KQXEditor\\\\shell\\\\open\\\\command", "", SessionVar.Expand("%AppFolder%\\\\MyProgram.exe \\"%1\\"") , REG_SZ);

The third (and optional) step is to associate an icon with files using the *.KQX file extension. We will set the icon for all KQX files to be the same icon that our KQXEditor (%AppFolder%\\MyProgram.exe) uses:

Registry Action: Set Value
Main Key: HKEY_CLASSES_ROOT
Sub Key: KQXEditor\\DefaultIcon
Value:
Data: %AppFolder%\\MyProgram.exe,0
Value Type: REG_SZ

Example:
Registry.SetValue(HKEY_CLASSES_ROOT, "KQXEditor\\\\DefaultIcon", "", SessionVar.Expand("%AppFolder%\\\\MyProgram.exe ,0\\")", REG_SZ);