Related to this: How to register file types/extensions with a WiX installer? but not a duplicate.
I need to handle existing file types (.jpg files).
I do not want my app to be the default handler for .jpg. I would just like to extend the "Open with" menu with a link to my app.
I see HKCR\.jpg\OpenWithList\
and HKCR\.jpg\OpenWithProgIds\
in the registry but I am not sure whether to write to these and how to do it correctly with WiX. Should I use something like this?
<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>
There are many ways to fail here (like Photo Mechanics did, the HKCR for image file types is a real mess after I have installed this software).
How to do this correctly with WiX?
The WiX tools follow the traditional compile and link model used to create executables from source code. At build time, the WiX source files are validated against the core WiX schema, then processed by a preprocessor, compiler, and linker to create the final result.
Adding a WiX setup project In Visual Studio, open your solution, and add a WiX project to it: go to the Visual Studio main menu and click File -> Add -> New Project to open the Add New Project dialog. Choose the Setup Project item in the Windows Installer XML node, specify the project name and click OK.
Here's a full, complete example with a bit more detail and cleaner code than in the linked question and should provide a better answer. Quite timely as I've recently finished porting the code posted previously, to use proper ProgId
elements so this is fresh in my mind ;)
In regards to the 'what here', you can pretty much use whatever you like :)
<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=""[APPLICATIONFOLDER]MyApp.exe" "%1"" 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=""%1"" /> <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=""[APPLICATIONFOLDER]MyApp.exe" "%1"" Type="string" /> </Component>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With