Hi All,
I have a GUI windows application that has some command line ( non-UI options ).
When the application is run from the command line, it detatches from the cmd process and still runs. For example, if I run
c:\> App.exe /quiet /testparam:1
I get a cmd prompt back striaght away. Whereas if I have a console app it obviously runs until int main() returns.
I was hoping that by not returning DialogProc() to WinMain when params are passed I'd essentially have a console app, but that doesn't seem to be the case. I'm currently doing
Code:
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
hInst = hInstance;
/*
* Tokenize lpCmdLine (command line options)
* and deal with various options.
*/
char *token;
token = strtok( lpCmdLine , " ");
bool bQuietMode = false;
/* Loop through tokenized lpCmdLine */
while ( token )
{
/* token is the commandline option */
if ( strcmp(token , "/csv") == 0 )
{
bQuietMode = true;
outputCSV();
}
token = strtok( NULL , " ");
}
/* If we've specified some cmd line options, don't show the GUI. */
if (!bQuietMode)
{
// The user interface is a modal dialog box
return DialogBox(hInstance, MAKEINTRESOURCE(DLG_MAIN), NULL, DialogProc);
}
else
{
return ERROR_SUCCESS;
}
}
The above code works, but returns straight away whilst the program still executes. How can I prevent it returning until execution is complete if it's in "Quiet Mode" ?
Thanks
Dave