How can I set an icon for an asscociated file using WiX?

前端 未结 4 2054
离开以前
离开以前 2021-01-12 14:24

My application install file is being generated using WiX. In the WiX configuration I am associating a file type that works with the application. How can I associate an icon

相关标签:
4条回答
  • 2021-01-12 14:34

    Please note that Dracos answer is not suffiecent for a complete icon/file association.

    The following code:

    This is how I did it. I declared:

    <Icon Id="Icon.exe" SourceFile="..\Installer\Graph.ico" /> 
    <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>
    

    Is only registering a file/icon association for the dialouges created by the application which is installed by the given wix-project. To get an icon that is shown overall for all the dialogues, desktop etc. in windows you also need to register your icon for a specific filetype (extension) in regedit.

    0 讨论(0)
  • 2021-01-12 14:39

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

    If your application handles its own file data type, you will need to register a file association for it. Put a ProgId inside your component. FileId should refer to the Id attribute of the File element describing the file meant to handle the files of this extension. Note the exclamation mark: it will return the short path of the file instead of the 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 have to specify the appropriate registry entries yourself 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' />
    
    0 讨论(0)
  • 2021-01-12 14:46

    This 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>
    
    0 讨论(0)
  • 2021-01-12 14:49

    I'd recommend following my stack overflow post located here for the simplest and most elegant way of embedding icons into a resource without the need for a c++ project in a managed .NET application.

    Next, here is the proper way to set 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 sample registers the default icon for a specific file extension (.stackoverflow) that is located in an assembly from step 1. It also shows how to create Windows Explorer associated right click commands as well as adds a menu item to the Windows Explorer New sub menu.

    Thanks

    -Blake Niemyjski

    0 讨论(0)
提交回复
热议问题