说,如果我右键单击某个文件,然后转到“打开方式”菜单,它将显示一个子菜单,类似于这个:
如何将自己的程序添加到“打开方式”列表中?
PS。请注意,在这种情况下我不需要来创建与特定文件扩展名的关联(用户通常双击打开它。)
PS2。我在技术上需要从MSI安装程序(我正在使用WiX)完成此操作,但如果有人可以建议API或注册表进行设置,我也可以通过自定义操作执行此操作,如果MSI / WiX不直接支持它。 / p>
答案 0 :(得分:1)
说,如果我正在制作" Text Zapper "应用程序,并希望将其与#34; Open With" .txt
个文件。这是WiX(MSI)布局的伪标记。它基本上定义了需要设置的注册表项。 (请注意,它没有为应用定义.txt
扩展名默认关联。)
<?define ProgId = "Text.Zapper.1" ?>
<?define GuiAppExeName = "txtzpr.exe" ?>
<?define ProductThis = "Text Zapper" ?>
<?define AppDescr = "Wonderful Text Zapper Application" ?>
<Component Id='IdTextZapper' Guid='*'>
<File Id='IdTextZapperExe' Name='$(var.GuiAppExeName)' DiskId='1' Source='$(var.Srctxtzpr)' KeyPath='yes' />
<!-- Extend the "open with" Windows Explorer function -->
<RegistryValue Root="HKLM" Key="SOFTWARE\Classes\$(var.ProgId)" Value="$(var.ProductThis)" Type="string" />
<RegistryValue Root="HKLM" Key="SOFTWARE\Classes\Applications\$(var.GuiAppExeName)" Name="FriendlyAppName" Value="$(var.ProductThis)" Type="string" />
<RegistryValue Root="HKLM" Key="SOFTWARE\Classes\Applications\$(var.GuiAppExeName)\shell\open" Name="FriendlyAppName" Value="$(var.ProductThis)" Type="string" />
<RegistryValue Root="HKLM" Key="SOFTWARE\Classes\Applications\$(var.GuiAppExeName)\shell\open\command" Value='"[INSTALLDIR]$(var.GuiAppExeName)" "%1"' Type="string" />
<RegistryValue Root="HKLM" Key="SOFTWARE\My Company\Text Zapper\Capabilities" Name="ApplicationDescription" Value="$(var.AppDescr)" Type="string" />
<RegistryValue Root="HKLM" Key="SOFTWARE\RegisteredApplications" Name="$(var.ProductThis)" Value="SOFTWARE\My Company\Text Zapper\Capabilities" Type="string" />
<RegistryValue Root="HKLM" Key="SOFTWARE\Classes\.txt\OpenWithProgIDs" Name="$(var.ProgId)" Value="" Type="string" />
<RegistryValue Root="HKLM" Key="SOFTWARE\Classes\.txt\OpenWithList\$(var.GuiAppExeName)" Value="" Type="string" />
<RegistryValue Root="HKLM" Key="SOFTWARE\Classes\Applications\$(var.GuiAppExeName)\SupportedTypes" Name=".txt" Value="" Type="string" />
<RegistryValue Root="HKLM" Key="SOFTWARE\My Company\Text Zapper\Capabilities\FileAssociations" Name=".txt" Value="$(var.ProgId)" Type="string" />
</Component>