How to set icon for asscociated file using WiX?

My application installation file is created using WiX. In the WiX configuration, I associate the type of file that works with the application. How to associate an icon with this file type in a WiX configuration?

+7
wix
Mar 12 '09 at 11:22
source share
3 answers

Here is how I did it. I declared:

<Icon Id="Icon.exe" SourceFile="..\Installer\Graph.ico" /> 

before </Product> and added it as a reference as follows:

 <ProgId Id='myApp.exe' Description='Some description' Advertise='yes' Icon='Icon.exe'> <Extension Id='xyz' ContentType='application/text'> <Verb Id='open' Sequence='10' Command='Open' Argument='"%1"' /> </Extension> </ProgId> 
+6
Mar 12 '09 at 13:22
source share

FROM: http://www.tramontana.co.hu/wix/lesson1.php#1.7

If your application processes its own file data type, you need to register a file association for it. Place the ProgId inside your component. FileId must refer to the Id attribute of the File element, which describes the file used to process files of this extension. Pay attention to the exclamation mark: it will return a short path to the file instead of a long one:

 <ProgId Id='AcmeFoobar.xyzfile' Description='Acme Foobar data file'> <Extension Id='xyz' ContentType='application/xyz'> <Verb Id='open' Sequence='10' Command='Open' Target='[!FileId]' Argument='"%1"' /> </Extension> </ProgId> 

To assign an icon to this file type, you must specify the appropriate registry entries inside your component:

 <Registry Id='FooIcon1' Root='HKCR' Key='.xyz' Action='write' Type='string' Value='AcmeFoobar.xyzfile' /> <Registry Id='FooIcon2' Root='HKCR' Key='AcmeFoobar.xyzfile' Action='write' Type='string' Value='Acme Foobar data file' /> <Registry Id='FooIcon3' Root='HKCR' Key='AcmeFoobar.xyzfile\DefaultIcon' Action='write' Type='string' Value='[INSTALLDIR]Foobar.exe,1' /> 
+7
Mar 12 '09 at 11:29
source share

I would recommend the following stack overflow message here for the simplest and most elegant way to embed icons in a resource without having to create a C ++ project in a managed .NET application.

Next, here is the correct way to install this via wix:

  <Component Id="stackoverflowFileRegistration" Guid="MY_GUID"> <RegistryKey Root="HKCR" Key=".stackoverflow" ForceCreateOnInstall="yes" ForceDeleteOnUninstall="yes"> <RegistryValue Value="stackoverflow.Document" Type="string" KeyPath="yes" /> <RegistryValue Name="Content Type" Value="application/stackoverflow" Type="string" /> <RegistryKey Key="ShellNew" ForceCreateOnInstall="yes" ForceDeleteOnUninstall="yes"> <RegistryValue Name="NullFile" Value="" Type="string" /> <RegistryValue Name="Data" Value="Default new document Content.. NOTE: you must use a MutiStringValue nodes for multi-line content...." Type="string"/> </RegistryKey> </RegistryKey> <RegistryKey Root="HKCR" Key="stackoverflow.Document" ForceCreateOnInstall="yes" ForceDeleteOnUninstall="yes"> <RegistryValue Value="stackoverflow Document" Type="string" /> <RegistryKey Key="DefaultIcon" ForceCreateOnInstall="yes" ForceDeleteOnUninstall="yes"> <RegistryValue Value="[INSTALLDIR]bin\stackoverflow.lib.dll, 1" Type="string" /> </RegistryKey> <RegistryKey Key="Shell" ForceCreateOnInstall="yes" ForceDeleteOnUninstall="yes"> <RegistryKey Key="openstackoverflowwebsite" ForceCreateOnInstall="yes" ForceDeleteOnUninstall="yes"> <RegistryValue Value="Open Stackoverflow" Type="string" /> <RegistryKey Key="command" ForceCreateOnInstall="yes" ForceDeleteOnUninstall="yes"> <RegistryValue Value="&quot;[INSTALLDIR]stackoverflow.exe&quot; /openwebsite &quot;%1&quot;" Type="string" /> </RegistryKey> </RegistryKey> </RegistryKey> </RegistryKey> </Component> 

This example registers the default icon for a specific file extension (.stackoverflow) that is in the assembly from step 1. It also shows how to create related Windows commands with the right mouse button, and also adds a menu item to Windows Explorer New submenu.

thank

-Blake Niemyjski

0
May 2 '12 at 2:33
source share



All Articles