How to add Windows file type association using InstallShield?

I wrote an application to take a file path (a file with a custom extension) as an argument, and then do some processing on it.

The idea is that I could associate (using Windows functionality) a user file with my executable application that I am installing (through the installer of the installation screen).

I would like to be able to double-click my file using a custom extension and transfer it to an executable file for processing.

However, the behavior that I get is as follows:

  • If I double-clicked my file (with user extension), it does nothing.
  • If I drag and drop the file into my executable program, it will work as expected.

So is it possible to make this work by simply double-clicking on my user file?

I think windows are trying to open a user file using an executable file, which may not match the passing it as an argument ?!

Any help was appreciated.

thanks KS

+4
source share
2 answers

Regardless of your installation method (installscript, MSI, etc.) you basically need to create multiple HKEY_CLASSES_ROOT entries. Depending on your method, there are various ways to solve it (for example, in the MSI installer created using the installation screen, if you follow the recommendations, it can also initiate installation recovery for your application if it detects problems.

Root you need: (we will pretend your extension isxyz)

  • In HKCR, create a new key named ".xyz" (here you can see many others.
  • In the default value, set the data for some name, which means something like "myapp.xyz"
  • Create a new HKCR key named "myapp.xyz" so that it matches what you created in 2
  • In the default setting, set the data to a descriptive label. For example, "My application data file"
  • Create a subsection called shell (you can set the default value here for "opening", which will then open the default action in explorer)
  • Create an Open Unit
  • Create a subsection called a team
  • In the default value for the command line, set the value to "c: \ path \ to \ installfolder \ appname.exe" "% 1" (check all quotation marks in this case)
  • You can also create a subsection in the "myapp.xyz" section with the name DefaultIcon that points to the icon file that will be associated with your extension in Explorer.

If you use installshield, a lot of things have been done for you. although in the past I had to tune it to fit the desired result in more complex applications with multiple file formats.

+4
source

Using InstallShield 2013:

For custom file type

  • Click the "Installation Designer" tab.
  • In the box on the left, expand "Organization" and select "Components."
  • In the list of components, expand the settings for the main source code, then expand Advanced Settings and select File Types.
  • Right-click Extensions and select New Extension. Enter an extension without a previous period.
  • Your extension should have a β€œverb” of β€œOpen,” automatically added for it when you created it. Choose this. Enter "Display Name", for example. "& Open with MyApp." Enter "Argument", for example. "% 1" (which passes the name of the exe file enclosed in quotation marks to handle long file names / spaces.)
  • Select a new extension from the list, then enter β€œProgID” for it. For example, "MyApp.Document".

To define a specific icon to associate with a type (and not an implicit exe icon):

  1. Click on the added "ProgID" ("MyApp.Document" or something else). Click in the "Icon" field, then click the "..." button that appears. This will allow you to go to the icon file.

For a "generic" file type

If the file type does not apply exclusively to your application, you can add your application to the list of options for opening this type, but not make it the default program or change the default icon. Here's how to achieve this ...

  • Go to the "Installation Designer" tab and follow the instructions for your custom file type .
  • In the box on the left, expand "Organization" and select "Components."
  • In the list of components, expand the primary exe settings, then select "Registry Data".
  • In the "Target computer frame", right-click "HKEY_CLASSES_ROOT" and select "Create" ... "Key". What is the file extension key (INCLUDING the host peroroid) for which you define the connection.
  • Right-click this new key and select "Create" ... "Default value". Then right-click on this default value, select "Modify". Enter ProgID for what should be the default application to open this type and specify the icon. You may need to check the registry to determine this value. For example, the default default value for a zip file is "CompressedFolder". Finding out this is the hardest part of this procedure.
  • Right-click on this new key and select "Create" ... "Key" again to create an additional key. Name the helper key "OpenWithProgids".
  • Right-click on the OpenWithProgids key and select "Create" ... "String Value". What is the default value for ProgId? Leave this value blank (β€œname” is β€œvalue”).
  • Right-click on the OpenWithProgids key and select "Create" ... "String Value" again. This time, name the value specified in ProgId for your application when you followed the instructions for the custom file type.
+3
source

All Articles