2010-05-05 68 views
28

與此相關:How to register file types/extensions with a WiX installer?但不是重複。如何使用WiX安裝程序將應用程序與現有文件類型關聯?

我需要處理現有的文件類型(.jpg文件)。

我不想成爲.jpg的默認處理程序,我只想通過鏈接指向我的應用程序來擴展「Open with」菜單。

我在註冊表中看到HKCR\.jpg\OpenWithList\和​​,但我不確定是否寫入這些以及如何使用WiX正確執行此操作。我應該使用這樣的東西嗎?

<ProgId Id='??what here?' Description='Jpeg handled by my App'> 
    <Extension Id='jpg' ContentType='image/jpeg'> 
    <Verb Id='openwithmyapp' Sequence='10' Command='OpenWithMyApp' Target='[!FileId]' Argument='"%1"' /> 
    </Extension> 
</ProgId> 

有許多方法如何在這裏失敗(比如Photo力學這樣做了,HKCR圖像文件類型是我已經安裝了這個軟件之後,一個真正的混亂)

如何正確使用維克斯做到這一點?

+0

不是sasha對鏈接問題的回答提供了這個嗎?尤其要注意五個RegistryValues,包括OpenWith ...鍵。 (或者可能有一個更清晰的方式來在WiX中指定這個)。 – 2010-05-06 13:26:50

+0

我對正在做什麼薩沙避免了什麼感興趣 - 我想了解哪些值用於說明/內容類型等。這裏有什麼?在我的問題。我也想知道哪些值是必需的,哪些不是,鏈接的答案似乎包含了一些可能不需要簡單地提供文件處理程序的東西。 – Marek 2010-05-07 11:30:26

+0

呃...我回寫了一段回答。儘快發佈更乾淨的代碼。 – saschabeaumont 2010-05-11 05:23:30

回答

49

下面是一個完整的完整示例,其中包含比鏈接問題更詳細和更清晰的代碼,並且應該提供更好的答案。相當及時,因爲我最近完成了移植之前發佈的代碼,使用適當的ProgId元素,所以這是我心中的新鮮;)

關於'什麼在這裏',你可以使用任何你喜歡的: )

<Icon Id="filetype.ico" SourceFile="filetype.ico" /> 
<Component Id="MyApp.exe" Directory="APPLICATIONFOLDER" Guid="*"> 
    <File Id="MyApp.exe" Name="MyApp.exe" KeyPath="yes"/> 

    <Shortcut Id="startmenuShortcut" Directory="ProgramMenuFolder" Name="MyApp" Icon="$(var.product).ico" IconIndex="0" WorkingDirectory="APPLICATIONFOLDER" Advertise="yes" /> 

    <!-- Capabilities keys for Vista/7 "Set Program Access and Defaults" --> 
    <RegistryValue Root="HKLM" Key="SOFTWARE\MyApp\Capabilities" Name="ApplicationDescription" Value="!(loc.ApplicationDescription)" Type="string" /> 
    <RegistryValue Root="HKLM" Key="SOFTWARE\MyApp\Capabilities" Name="ApplicationIcon" Value="[APPLICATIONFOLDER]MyApp.exe,0" Type="string" /> 
    <RegistryValue Root="HKLM" Key="SOFTWARE\MyApp\Capabilities" Name="ApplicationName" Value="!(loc.ApplicationName)" Type="string" /> 
    <RegistryValue Root="HKLM" Key="SOFTWARE\MyApp\Capabilities\DefaultIcon" Value="[APPLICATIONFOLDER]MyApp.exe,1" Type="string" /> 
    <RegistryValue Root="HKLM" Key="SOFTWARE\MyApp\Capabilities\FileAssociations" Name=".xyz" Value="MyApp.Document" Type="string" /> 
    <RegistryValue Root="HKLM" Key="SOFTWARE\MyApp\Capabilities\MIMEAssociations" Name="application/xyz" Value="MyApp.Document" Type="string" /> 
    <RegistryValue Root="HKLM" Key="SOFTWARE\MyApp\Capabilities\shell\Open\command" Value="&quot;[APPLICATIONFOLDER]MyApp.exe&quot; &quot;%1&quot;" Type="string" /> 
    <RegistryValue Root="HKLM" Key="SOFTWARE\RegisteredApplications" Name="MyApp" Value="SOFTWARE\MyApp\Capabilities" Type="string" /> 

    <!-- App Paths to support Start,Run -> "myapp" --> 
    <RegistryValue Root="HKLM" Key="SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\MyApp.exe" Value="[!MyApp.exe]" Type="string" /> 
    <RegistryValue Root="HKLM" Key="SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\MyApp.exe" Name="Path" Value="[APPLICATIONFOLDER]" Type="string" /> 

    <!-- Extend to the "open with" list + Win7 jump menu pinning --> 
    <RegistryValue Root="HKLM" Key="SOFTWARE\Classes\Applications\MyApp.exe\SupportedTypes" Name=".xyz" Value="" Type="string" /> 
    <RegistryValue Root="HKLM" Key="SOFTWARE\Classes\Applications\MyApp.exe\shell\open" Name="FriendlyAppName" Value="!(loc.ApplicationName)" Type="string" /> 

    <!-- MyApp.Document ProgID --> 
    <RegistryValue Root="HKLM" Key="SOFTWARE\Classes\MyApp.Document" Name="FriendlyTypeName" Value="!(loc.DescXYZ)" Type="string" /> 
    <ProgId Id="MyApp.Document" Description="!(loc.DescXYZ)" Icon="filetype.ico" Advertise="yes"> 
     <Extension Id="xyz"> 
      <Verb Id="open" Command="!(loc.ExplorerMenuOpenXYZ)" Argument="&quot;%1&quot;" /> 
      <MIME Advertise="yes" ContentType="application/xyz" Default="yes" /> 
     </Extension> 
    </ProgId> 

    <!-- Optional: add an 'Edit with XYZ' to 'right click' even when not associated --> 
    <RegistryValue Root="HKLM" Key="SOFTWARE\Classes\SystemFileAssociations\.xyz\shell\edit.MyApp.exe" Value="!(loc.ExplorerMenuEditXYZ)" Type="string" /> 
    <RegistryValue Root="HKLM" Key="SOFTWARE\Classes\SystemFileAssociations\.xyz\shell\edit.MyApp.exe\command" Value="&quot;[APPLICATIONFOLDER]MyApp.exe&quot; &quot;%1&quot;" Type="string" /> 
</Component> 
+0

很酷的例子!你在哪裏收集了所有這些註冊表項所需的信息?你有鏈接到MSDN文章? – 2010-11-18 22:21:09

+3

請嘗試http://msdn.microsoft.com/en-us/library/cc144154(VS.85).aspx – saschabeaumont 2010-12-02 01:25:22

+1

這個例子,尤其是在ProgId部分,看起來很像我的WiX代碼,它接管的文件擴展名是已經註冊。處理原始問題的訣竅是什麼?這是爲了防止ProgId/Extension/Verb元素接管現有的擴展? 示例:我安裝了一個處理JPG擴展的程序。我不想讓我的程序成爲默認程序。我想要一個廣告註冊。我想要「開放」。我有默認程序,註冊打開方式等都已經搞清楚了,但是如何防止強制自己作爲默認值? – 2012-11-26 22:45:16

相關問題