Page 1 of 1

Handling Files Opened In Win Explorer

Posted: Sat Jul 07, 2012 10:16 am
by RandomDever
I have done some searching in google but I can't seem to find anything.
Why I'm trying to do is this:
I have a proprietary file format that is associated to my application.
When I double click a file of that type it opens the application but doesn't actually open the file.
I want it to open the file.
How would I go about doing that?

Thank You.

Re: Handling Files Opened In Win Explorer

Posted: Sat Jul 07, 2012 12:28 pm
by bbguimaraes
Forgive me for being obvious, but isn't the file path passed as the first argument?

Code: Select all

int main(int argc, char ** argv) {
    App app;

    if(argc > 1)
        app.open(argv[1]);

    // ...
}

Re: Handling Files Opened In Win Explorer

Posted: Sat Jul 07, 2012 1:43 pm
by RandomDever
Well thank you.
Now I finally know what those main parameters are for.
And it's now that obvious.
It's only obvious to someone who programs outside of DOS ( which I didn't ).
So thanks. :)

Re: Handling Files Opened In Win Explorer

Posted: Sat Jul 07, 2012 2:10 pm
by bbguimaraes
OK, glad I could help.

Re: Handling Files Opened In Win Explorer

Posted: Sun Jul 08, 2012 4:20 am
by jakson15
"I have a proprietary file format that is associated to my application.
When I double click a file of that type it opens the application but doesn't actually open the file."

How did you achieve this?
Opening my application from an unknown file?

Re: Handling Files Opened In Win Explorer

Posted: Sun Jul 08, 2012 8:56 am
by dandymcgee
jakson15 wrote:"I have a proprietary file format that is associated to my application.
When I double click a file of that type it opens the application but doesn't actually open the file."

How did you achieve this?
Opening my application from an unknown file?
Windows associates file extensions with applications. This is why when you open a file with an extensions for which you do not have the proper application to open it with, you see the "Open With..." dialog which forces you to manually choose an application. When you check "Always use this application to open this file type", Windows saves that association as a key in the registry. You can associate any extension you want with your own application, but keep in mind that doing so will override an existing association. For example, if you associated the .txt extension with you application, double-clicking a text file will no longer open it in Notepad, or whatever you default text editor is, but rather with your application.