wix - 将程序添加到 Windows 8 上的文件扩展名的 “Open With” 菜单

标签 wix registry windows-installer

与此类似的问题 have been asked before但我相信 Windows 8 发生了变化,因此这不是重复的。

方法一

什么看起来最好 windows desktop documentation建议程序使用 OpenWithProgids。虽然 some MSDN documentation报告此注册表项仅在 Windows XP 中受支持,other documentation表示它以某种方式与 Windows 8 一起引入的 Windows 应用商店一起使用。仅在我的计算机上查看,大多数程序仍然使用此注册表项,因此我计划添加它,而不是仅仅被文档混淆。

方法二

Application Registration窗口桌面文档的部分建议将程序添加到“打开方式”上下文菜单的方法是使用 SupportedTypes 注册表项。

总结

这两种方法都适用于 Windows 7,但似乎都不适用于 Windows 8。

有些人可能会建议尝试“默认程序”界面,但是,尽管这是一个好主意,documentation on it通常会将您指向其他地方以进入“打开方式”菜单。我通常希望应用程序保持在“打开方式”菜单上,无论它当前是否是默认程序。

不过,请继续关注 this thread 中的默认程序主题。有人“偶然发现”了一个解决方案,在将程序添加到“打开方式”菜单后将其设置为默认程序。不幸的是,我的文件扩展名在我的系统上没有得到相同的行为。

<Component Id="ConsoleApplication" Guid="*">
  <File Id="ConsoleApplication.exe" Name='ConsoleApplication.exe' DiskId='1'
        Source='$(var.ConsoleApplication.TargetDir)/ConsoleApplication.exe'
        KeyPath='yes' />

  <!-- ProgID (always required) -->
  <RegistryValue Root="HKLM"
                 Key="SOFTWARE\Classes\ConsoleApplication.MyProgId"
                 Name="FriendlyTypeName"
                 Value="ConsoleApplication ProgID"
                 Type="string" />
  <ProgId Id="ConsoleApplication.MyProgId"
        Description="ConsoleApplication MyProgId"
        Advertise="yes">
    <Extension Id="xyz">
      <Verb Id="open"
            Command="Open"
            Argument="&quot;%1&quot;"/>
    </Extension>
  </ProgId>

  <!-- Method 1: Add to the "Open With" menu using a ProgID -->
  <RegistryValue Root="HKLM"
                 Key="SOFTWARE\Classes\.xyz\OpenWithProgids"
                 Name="ConsoleApplication.MyProgId"
                 Value=""
                 Type="string" />

  <!-- Method 2: Add to the "Open With" menu using "Application Registration" -->
  <RegistryValue Root="HKLM"
                 Key="SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\ConsoleApplication.exe"
                 Value="[!ConsoleApplication.exe]"
                 Type="string" />
  <RegistryValue Root="HKLM"
                 Key="SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\ConsoleApplication.exe"
                 Name="Path"
                 Value="[INSTALLFOLDER]"
                 Type="string" />
  <RegistryValue Root="HKLM"
                 Key="SOFTWARE\Classes\Applications\ConsoleApplication.exe\SupportedTypes"
                 Name=".xyz"
                 Value=""
                 Type="string" />
  <RegistryValue Root="HKLM"
                 Key="SOFTWARE\Classes\Applications\ConsoleApplication.exe\shell\open"
                 Name="FriendlyAppName"
                 Value="My FriendlyAppName"
                 Type="string" />

  <!-- "Default Programs" registration -->
  <RegistryValue Root="HKLM"
                 Key="SOFTWARE\ConsoleApplication\Capabilities"
                 Name="ApplicationDescription"
                 Value="Console application."
                 Type="string" />
  <RegistryValue Root="HKLM"
                 Key="SOFTWARE\ConsoleApplication\Capabilities"
                 Name="ApplicationIcon"
                 Value="[INSTALLFOLDER]ConsoleApplication.exe,0"
                 Type="string" />
  <RegistryValue Root="HKLM"
                 Key="SOFTWARE\ConsoleApplication\Capabilities"
                 Name="ApplicationName"
                 Value="ConsoleApplication"
                 Type="string" />
  <RegistryValue Root="HKLM"
                 Key="SOFTWARE\ConsoleApplication\Capabilities\DefaultIcon"
                 Value="[INSTALLFOLDER]ConsoleApplication.exe,0"
                 Type="string" />
  <RegistryValue Root="HKLM"
                 Key="SOFTWARE\ConsoleApplication\Capabilities\FileAssociations"
                 Name=".xyz"
                 Value="ConsoleApplication.MyProgId"
                 Type="string" />
  <RegistryValue Root="HKLM"
                 Key="SOFTWARE\ConsoleApplication\Capabilities\shell\open\command"
                 Value="&quot;[INSTALLFOLDER]ConsoleApplication.exe&quot; &quot;%1&quot;"
                 Type="string" />
  <RegistryValue Root="HKLM"
                 Key="SOFTWARE\RegisteredApplications"
                 Name="ConsoleApplication"
                 Value="SOFTWARE\ConsoleApplication\Capabilities"
                 Type="string" />
</Component>

最佳答案

读这个:
https://superuser.com/questions/690106/add-items-to-the-open-with-list-in-windows-8
这显然是 Win 8 中的新功能,但除非您提供这两个属性,否则应用程序不会出现在菜单上。

关于wix - 将程序添加到 Windows 8 上的文件扩展名的 “Open With” 菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23175455/

相关文章:

c++ - MSI 安装的数据持久化

windows-vista - Windows 注册表项名称的最大长度是多少?

windows - DLL 和注册表有什么问题?

xpath - 如何在WiX中使用XmlConfig编辑元素?

c# - Wix:从 C# 自定义操作传回属性

installation - 是否可以在 Installshield 2012 PRQ 中使用逻辑 OR 或否定条件?

windows - 如何从命令行提取.msi功能?

c# - 为什么我的 WiX 自定义操作会抛出 System.IO.FileNotFoundException?

c# - Wix 更改 exe 安装程序图标

c++ - 使用 Windows API 获取文件关联