我正在使用WiX生成我的应用程序安装文件。在WiX配置中,我将一个与应用程序配合工作的文件类型关联起来。如何在WiX配置中为这个文件类型关联一个图标呢?
我正在使用WiX生成我的应用程序安装文件。在WiX配置中,我将一个与应用程序配合工作的文件类型关联起来。如何在WiX配置中为这个文件类型关联一个图标呢?
来源: https://www.firegiant.com/wix/tutorial/getting-started/beyond-files/
如果您的应用程序处理自己的文件数据类型,则需要为其注册文件关联。将一个ProgId放在您的组件中。FileId应该引用描述处理此扩展名文件的File元素的Id属性。请注意感叹号:它会返回文件的短路径而不是长路径:
<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>
要将图标分配给此文件类型,您必须在组件内自己指定相应的注册表条目:
<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' />
<Icon Id="Icon.exe" SourceFile="..\Installer\Graph.ico" />
我在 </Product>
标签之前添加了它,并将其作为以下引用:
<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>
我建议您遵循我的stackoverflow帖子,位于这里,以最简单和最优雅的方式将图标嵌入到资源中,而无需在托管的.NET应用程序中使用c++项目。
接下来,这是通过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=""[INSTALLDIR]stackoverflow.exe" /openwebsite "%1"" Type="string" />
</RegistryKey>
</RegistryKey>
</RegistryKey>
</RegistryKey>
</Component>
这个示例为步骤1中位于程序集中的特定文件扩展名(.stackoverflow)注册默认图标。它还展示了如何创建与Windows资源管理器相关联的右键命令,并将菜单项添加到Windows资源管理器的“新建”子菜单中。
谢谢
-Blake Niemyjski
<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>
仅为由给定的wix项目安装的应用程序创建的对话框注册文件/图标关联。 要在Windows中显示所有对话框、桌面等的图标,还需要在regedit中为特定的文件类型(扩展名)注册您的图标。