tdubroff
asked on
Dropping a file onto an applications icon
I would like it so that I can drop a file onto my application's icon and then the application would start up with information gleaned from the file. I'm using MS VC++ 5.0 and have experimented with the WM_DROPFILES message, but that only appears to work once the application has already started. Any help would be appreciated.
ASKER
You get command line args automatically with an AppWizard generated application.
Ronslow, can you be a little more specific? I have a global application called The App that runs my modal dialog box. Where do I insert the use of command-line arguments? I have put an OnDropFiles(HDROP hDrop) message handler in both The App and my dialog box, but that only accepts dropped files after the application has started up.
ASKER
Include this code in your application's InitInstance
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
Then look at cmdInfo to determine what to do with the file
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
Then look at cmdInfo to determine what to do with the file
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Thanks for the help Ronslow. I got it working.
ASKER
Glad to help
void main(int argc, char* argv[])
{
//argc is the argument count
if (argc > 1)
//read in your file whose name is in argv[1]
//or do whatever file manipulation you are doing
ReadFile( argv[1] );
//put the rest of your main subroutine in here
}