Alex Rivera | Logout

How to associate a Windows application with a particular file type but share that association with other applications?

Asked 2009-10-14T21:26:49.953
20

If I create a new app, and associate with, say, the .xml file extension on a particular computer, when someone double clicks the .xml file, it will launch my app and pass the file as parameter. But Windows seems to know what other files have the ability to work with that file type. How is that set up?

Also, when I save a Microsoft Word file as an .xml file, then later double-click on the file, it will launch Microsoft Word, even though the .xml file type is associated with something else, such as Internet Explorer. Seems like there may be a stub associated with .xml file type which when invoked looks at the content and launches the appropriate app.

Is there a Windows API, or some kind of a standard way to do that?

What I wanted to create an app to do exactly what Word is doing -- i.e. save file in the .xml format, but when double-clicked, launches the my app instead of Internet Explorer.

Edit
Report

1 Answer

3

Well, all file associations are stored in the registry. There's an article, "Understanding MS Windows File Associations" that may help.

Beyond that, there are many ways to create file associations programmatically. Though most often this is done in the installer. For example, my favorite installation system NSIS has a macro to handle this: http://nsis.sourceforge.net/FileAssoc

But then there's the challenge of setting a default program to open a certain file type. I don't know what language or install system you're planning on using to do this but it appears that question is answered here for NSIS. Surely Microsoft also has documentation for their way of doing this with Windows Installer. But as you can probably guess, I'm more of an NSIS guy. ;)

answered 2009-10-14T21:37:35.213

Your Answer