Ore*_*ost 36 installation installer windows-installer wix wix3
我没有在WiX文档(或Google)中找到这个问题的明确答案.当然我可以在HKCR中编写相应的注册表项,但这让我觉得很脏,我希望这是一个标准的任务,应该有一个很好的默认解决方案.
对于奖励积分,我想知道如何使其"安全",即不要覆盖文件类型的现有注册,并且只有在安装期间注册并且未更改时才删除卸载时的注册.
sas*_*ont 20
不幸的是,没有办法与Windows Installer建立"安全"关联.
我们只是将所有内容写入注册表,然后有一个单独的组件来接管系统范围的默认值,并且仅在没有其他应用程序已将自身注册为默认值时才安装.
使用Vista有新的"默认程序"界面,再次将所有内容写入注册表.这是我们在安装程序中使用的完整示例.(WiX 3.0)
更新:自我的原始答案已经过去了12个月,我对文件关联有了更好的理解.而不是手动编写所有内容我现在使用适当的ProgId定义来改进对广告包的处理.请参阅针对此问题发布的更新代码.
<Component ....>
<RegistryValue Root="HKLM" Key="SOFTWARE\AcmeFoobar\Capabilities" Name="ApplicationDescription" Value="ACME Foobar XYZ Editor" Type="string" />
<RegistryValue Root="HKLM" Key="SOFTWARE\AcmeFoobar\Capabilities" Name="ApplicationIcon" Value="[APPLICATIONFOLDER]AcmeFoobar.exe,0" Type="string" />
<RegistryValue Root="HKLM" Key="SOFTWARE\AcmeFoobar\Capabilities" Name="ApplicationName" Value="ACME Foobar" Type="string" />
<RegistryValue Root="HKLM" Key="SOFTWARE\AcmeFoobar\Capabilities\DefaultIcon" Value="[APPLICATIONFOLDER]AcmeFoobar.exe,1" Type="string" />
<RegistryValue Root="HKLM" Key="SOFTWARE\AcmeFoobar\Capabilities\FileAssociations" Name=".xyz" Value="AcmeFoobar.Document" Type="string" />
<RegistryValue Root="HKLM" Key="SOFTWARE\AcmeFoobar\Capabilities\MIMEAssociations" Name="application/xyz" Value="AcmeFoobar.Document" Type="string" />
<RegistryValue Root="HKLM" Key="SOFTWARE\AcmeFoobar\Capabilities\shell\Open\command" Value=""[APPLICATIONFOLDER]AcmeFoobar.exe" "%1"" Type="string" />
<RegistryValue Root="HKLM" Key="SOFTWARE\RegisteredApplications" Name="Acme Foobar" Value="SOFTWARE\AcmeFoobar\Capabilities" Type="string" />
<RegistryValue Root="HKLM" Key="SOFTWARE\Classes\.xyz" Name="Content Type" Value="application/xyz" Type="string" />
<RegistryValue Root="HKLM" Key="SOFTWARE\Classes\.xyz\AcmeFoobar.Document\ShellNew" Value="" Type="string" />
<RegistryValue Root="HKLM" Key="SOFTWARE\Classes\.xyz\OpenWithList\AcmeFoobar.exe" Value="" Type="string" />
<RegistryValue Root="HKLM" Key="SOFTWARE\Classes\.xyz\OpenWithProgids" Name="AcmeFoobar.Document" Value="" Type="string" />
<RegistryValue Root="HKLM" Key="SOFTWARE\Classes\Applications\AcmeFoobar.exe\SupportedTypes" Name=".xyz" Value="" Type="string" />
<RegistryValue Root="HKLM" Key="SOFTWARE\Classes\Applications\AcmeFoobar.exe\shell\open" Name="FriendlyAppName" Value="ACME Foobar" Type="string" />
<RegistryValue Root="HKLM" Key="SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\AcmeFoobar.exe" Value="[!AcmeFoobar.exe]" Type="string" />
<RegistryValue Root="HKLM" Key="SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\AcmeFoobar.exe" Name="Path" Value="[APPLICATIONFOLDER]" Type="string" />
<RegistryValue Root="HKLM" Key="SOFTWARE\Classes\SystemFileAssociations\.xyz\shell\edit.AcmeFoobar.exe" Value="Edit with ACME Foobar" Type="string" />
<RegistryValue Root="HKLM" Key="SOFTWARE\Classes\SystemFileAssociations\.xyz\shell\edit.AcmeFoobar.exe\command" Value=""[APPLICATIONFOLDER]AcmeFoobar.exe" "%1"" Type="string" />
</Component>
<Component ....>
<ProgId Id="AcmeFoobar.Document" Description="ACME XYZ Document">
<Extension Id="pdf" ContentType="application/xyz">
<Verb Id="open" Command="Open" TargetFile="[APPLICATIONFOLDER]AcmeFoobar.exe" Argument="%1" />
</Extension>
</ProgId>
<Condition><![CDATA[DEFAULTVIEWER=1]]></Condition>
</Component>
Run Code Online (Sandbox Code Playgroud)
Ore*_*ost 12
经过一些额外的研究,我在WiX教程中找到了对这个问题的部分答案.它显示了一个广告解决方案,并不适用于WiX 3.0,但鉴于这些信息,我想出来了.将ProgId元素添加到包含可执行文件的组件中,如下所示:
<ProgId Id="MyApplication.MyFile" Description="My file type">
<Extension Id="myext" ContentType="application/whatever">
<Verb Id="open" Command="open" TargetFile="MyApplication.exe" Argument=""%1""/>
</Extension>
</ProgId>
Run Code Online (Sandbox Code Playgroud)
myext是没有点的文件扩展名,MyApplication.exe是可执行文件的文件ID(不是名称)(即File元素的Id属性).这将使用您的可执行文件注册文件类型,并将提供一个默认图标(带有应用程序图标的白页),这足以满足我的需求.如果你想指定一个专用图标,你似乎仍然需要自己做,如下所示(链接教程中的代码):
<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' />
Run Code Online (Sandbox Code Playgroud)
虽然我没有为我的奖金问题找到一个好的解决方案.
编辑:我在上一个答案出现之前开始写这篇文章.但是,与之前的答案相比,我的解决方案确实有效.
"如果你的应用程序处理它自己的文件数据类型,你需要为它注册一个文件关联.把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>
Run Code Online (Sandbox Code Playgroud)
参考:https://www.firegiant.com/wix/tutorial/getting-started/beyond-files/