Handling Files Opened In Win Explorer

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
RandomDever
Chaos Rift Regular
Chaos Rift Regular
Posts: 198
Joined: Thu Mar 26, 2009 8:42 pm
Current Project: My Engine
Programming Language of Choice: C++

Handling Files Opened In Win Explorer

Post 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.
User avatar
bbguimaraes
Chaos Rift Junior
Chaos Rift Junior
Posts: 294
Joined: Wed Apr 11, 2012 4:34 pm
Programming Language of Choice: c++
Location: Brazil
Contact:

Re: Handling Files Opened In Win Explorer

Post 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]);

    // ...
}
RandomDever
Chaos Rift Regular
Chaos Rift Regular
Posts: 198
Joined: Thu Mar 26, 2009 8:42 pm
Current Project: My Engine
Programming Language of Choice: C++

Re: Handling Files Opened In Win Explorer

Post 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. :)
User avatar
bbguimaraes
Chaos Rift Junior
Chaos Rift Junior
Posts: 294
Joined: Wed Apr 11, 2012 4:34 pm
Programming Language of Choice: c++
Location: Brazil
Contact:

Re: Handling Files Opened In Win Explorer

Post by bbguimaraes »

OK, glad I could help.
jakson15
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 6
Joined: Sun Dec 05, 2010 11:25 am
Favorite Gaming Platforms: Dreamcast, PC
Programming Language of Choice: c++

Re: Handling Files Opened In Win Explorer

Post 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?
User avatar
dandymcgee
ES Beta Backer
ES Beta Backer
Posts: 4709
Joined: Tue Apr 29, 2008 3:24 pm
Current Project: https://github.com/dbechrd/RicoTech
Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
Programming Language of Choice: C
Location: San Francisco
Contact:

Re: Handling Files Opened In Win Explorer

Post 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.
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches! :twisted:
Post Reply