How to associate Win32 app with existing file type?

a b 16 Reputation points
2022-09-28T20:13:04.29+00:00

Hello

I'm trying to associate my Win32 desktop app with existing file type when it's installed (app uses MSI installer via WiX).

In Microsoft documentation I see two methods to do this:

  1. Applications subkey
    Register my application in HKEY_CLASSES_ROOT\Applications subtree and add file type to SupportedTypes subkey
    https://learn.microsoft.com/en-us/windows/win32/shell/app-registration#using-the-applications-subkey
  2. Progids
    Add Progid subkey for my app in HKEY_CLASSES_ROOT tree and then adding it to OpenWithProgIDs subkey for file type
    https://learn.microsoft.com/en-us/windows/win32/shell/how-to-include-an-application-on-the-open-with-dialog-box

Experimentation shows that both methods work, but which one should I use?

My app supports Windows 8.1/10/11.

Windows 10
Windows 10
A Microsoft operating system that runs on personal computers and tablets.
10,657 questions
Windows
Windows
A family of Microsoft operating systems that run across personal computers, tablets, laptops, phones, internet of things devices, self-contained mixed reality headsets, large collaboration screens, and other devices.
4,770 questions
Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,426 questions
Windows 11
Windows 11
A Microsoft operating system designed for productivity, creativity, and ease of use.
8,218 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Martin Byskov 1 Reputation point
    2022-09-29T08:52:59.047+00:00

    Hi

    Use option 2, and DISM to set assoc. http://woshub.com/managing-default-file-associations-in-windows-10/

    Windows 10 uses another approach for users to set default applications.

    0 comments No comments

  2. Junjie Zhu - MSFT 15,056 Reputation points Microsoft Vendor
    2022-09-29T09:04:14.253+00:00

    Hello @a b ,
    Welcome to Microsoft Q&A!

    Both methods work in win10 and win11.
    Using SupportedTypes seems more convenient.

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

    ----------

      <RegistryValue Root="HKLM"  
                     Key="SOFTWARE\Classes\Applications\ConsoleApplication11.exe\SupportedTypes"  
                     Name=".xyz"  
                     Value=""  
                     Type="string" />  
    

    I haven't tested them in Win8.1 yet, I searched for something, it seems need to pay attention to check HKEY_CURRENT_USER\Software\Microsoft\Windows\ShellNoRoam\MUICache.

    Thank you.
    Junjie


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.