VC++: read cmdline arguments
Posted on 2004-09-20
I'm using the following code:
int APIENTRY WinMain(HINSTANCE hInstance,
int nCmdShow )
bool bOK = false;
//Read CmdLine's argument(s):
CmdLine = (char *) lpCmdLine;
// Next line can be used for Debugging purposes:
//MessageBox(0,CmdLine,"A r g u m e n t - Computername",MB_OK);
computername = (char *) CmdLine;
if (strcmp(computername ,"") == 0)
MessageBox(0,"No argument has been supplied!","I n f o r m a t i o n",MB_OK);
Now I want to introduce a switch like "-debug".
This switch I want to use to display some debugging information.
myprog.exe computername <== this is working
myprog.exe -debug computername <== that is my target
myprog.exe computername -debug <== that is my target (which one is better)
If anyone knows a solution, please modify the above's code accordingly (I'm using VC++6.0).
Thank you very much for every answer.