Running File Associated with Executable

Apr 20, 2013 at 2:27am
How exactly would I go about running a file via double-clicking it, then having my console executable open it and read it's contents? My problem isn't in the reading from the file, it's how to read the file that's associated with the executable by the user. For example, "*.ocmd" files are associated with the exectuable. I'm on Windows 7 x64.

Would I pass it on like a regular argument session?:

int main(int argc, char ** [] argv)
Apr 20, 2013 at 6:25am
Use "Open with" command and select your executable. Your program should get filename as argument 1.
Or you can dig the registry for existing examples of file handling to do something more complex.
This: http://msdn.microsoft.com/en-us/library/cc144171.aspx#dynamic_behavior might help ypu
Apr 20, 2013 at 12:15pm
Okay. And since my program gets argument 1 as the executable name, I need to take argument 2 as the filename. Then I ifstream the file with the argument 2 and do what I need to do. Thanks.
Apr 20, 2013 at 1:07pm
Exetuable name is the first argument or argument 0. Array indexes start with 0!
Topic archived. No new replies allowed.