How to register your program for file extensions shared with other programs

Heath Stewart

One frequently asked question is, “how do we register our program for a file extension when other versions (or programs) that handle it might also be installed?”

The overarching question is really about how to have non-shared resources both write to a shared resource.  But in the case with the Windows registry and file associations in general, your file can only be associated with one program. That is, double-clicking on the file can only open one program unless some other intermediate system decides otherwise.

Windows Vista introduced such a system. The Default Programs feature – which includes the Set Program Access and Computer Defaults (SPAD) introduced in Windows XP – provides the ability for programs to claim file extensions, MIME types, and protocol schemes as something they handle but still puts the user in control of which program actually does handle those things. The feature also includes the ability for a program to launch the related control panel applet showing all the associations the program can handle, such as the following example for Visual Studio 2013 on Windows 8.1:


I have created a sample that demonstrates this using a simple text editor, Contoso Editor. There are two versions written in C# and Visual Basic representing two distinct programs that can handle the .contoso file extension (which may be either plain text or rich text/RTF). It’s a no-frills example that also shows how to programmatically launch a dialog like the one you see above with your program instead.

This is accomplished programmatically using the IApplicationAssociationRegistrationUI interface. I’ve created a simple RCW to show how this is done in managed code, though in native code just CoCreateInstance CLSID_ApplicationAssociationRegistrationUI from shobjidl.h.

See the sample solution for more information.

1 comment

Discussion is closed. Login to edit/delete existing comments.

  • Jean-Francois Cosse 0

    The link to the sample is unfortunately broken. I have tried to search around but could not find the sample anywhere. Could you please upload it to e.g. Github or provide a working link? Thanks!

Feedback usabilla icon