Open files with...

I was curious how I could make it possible to set my program as the "default program" for opening a file type (like if you click on a .html file the computer knows to open firefox instead of explorer).
Should I be looking into COM functions or shell functions.
I'm not sure how to set it up on either side, the user has to click on a file before it will open, but how does my program realize that the computer wants the program to load and display that file?
Is it only possible if I actually set up a GUID/instal into the registry?

Sorry, rambling there, I'm obviously a bit lost. Main question;
Should I focus on shell functions or COM functions, do I need to learn both or is it something else I haven't mentioned?
Last edited on
As a beginner, I'd be writing raw things to the system registry. I'm not knowledged to this part of Windows.
closed account (Dy7SLyTq)
same here, but a quick search on google found this
Yep, that was a good link for setting up the registry to tell the OS that such-n-such file should be opened with my program. I've never made changes to a registry before, so I'm a bit scared to actually try it...
As far as the way the program knows how to open the file, could the information be inside of pCmdLine;

int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow);

I can't think of any other way that the OS can tell the program what file path needs to be opened... Does anyone know how to actually access that CmdLine information? I've been running my own google searches with little results so far.
Last edited on
I think I got that part. I will have to actually set up the registry portion first before I can test it, but this link at least shows how to access the info in CmdLine;

I'll be working on setting up the registry info, so I'll be off-site for several hours.

Thank you for all the help.
Topic archived. No new replies allowed.