How to associate a certain file type for my application?

Rohan Pande 445 Reputation points
2023-12-14T11:15:46.3766667+00:00

Hi,

I have an application that is being purely written in C++ and I want to associate a file type of a certain extension like ('.xyz').

Requirement is that if I double click on a '.xyz' file if my application is available, it should launch my application irrespective my application is running or not.

I have looked through some documentation, but I wasn't understanding much about it. There it was talking about ProgIDs. I am new to this so couldn't understand it properly and wasn't able to try it out.

Reference links that I have gone through:

  1. https://free.blessedness.top/en-us/windows/win32/shell/how-to-register-a-file-type-for-a-new-application
  2. https://free.blessedness.top/en-gb/windows/win32/shell/fa-sample-scenarios

Can someone help me in this? Thanks in advance.

Windows for business | Windows Client for IT Pros | User experience | Other
Developer technologies | C++
Developer technologies | C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
0 comments No comments
{count} votes

Answer accepted by question author
  1. Castorix31 91,191 Reputation points
    2023-12-14T12:25:45.5333333+00:00

    I don't have Windows 11, but on Windows 10 a simple way is with

    HKEY_CLASSES_ROOT\.xyz\shell\open\command

    with for example, for a test :

    "E:\Sources\Test7\Debug\test7.exe" "%1"

    =>

    User's image


2 additional answers

Sort by: Most helpful
  1. Minxin Yu 13,506 Reputation points Microsoft External Staff
    2023-12-14T12:27:26.88+00:00

    Hi, Rohan Pande

    Add the .xyz key in registry root:
    Computer\HKEY_CLASSES_ROOT\.xyz
    Change the key's default value to your app name.

    User's image

    Then add sub keys below:
    User's image

    Modify the command's default value.
    Such as :

    "XXX\yourapp.exe" "%1"
    

    Use CMD to notify the system:

    assoc .xyz=your app's name
    

    enter image description here Sample:

    enter image description here

    Best regards,

    Minxin Yu


    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.


  2. Sal 0 Reputation points
    2025-10-14T13:10:12.3433333+00:00

    You can use this package/tool to do this for Windows 10/11 now: https://github.com/mukunku/dotnet-file-associator

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.