Does the SW_HIDE flag really have an effect on console programs?
Yes, it does. My code is as follows:
bool ExecuteAndWaitForTermination(const char *progName, const char *progParams)
{
SHELLEXECUTEINFO shellInfo;
memset(&shellInfo, 0, sizeof(SHELLEXECUTEINFO));
shellInfo.cbSize = sizeof(SHELLEXECUTEINFO);
shellInfo.hwnd = NULL;
shellInfo.lpVerb = "open";
shellInfo.lpFile = progName;
shellInfo.lpParameters = progParams;
shellInfo.nShow = SW_HIDE;
shellInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
bool res = ShellExecuteEx(&shellInfo);
if (res)
WaitForSingleObject(shellInfo.hProcess, INFINITE);
return res;
}
It works perfectly on many machines, except one, where the WGET application executed in the above way shows up a full-screen console window, interrupting people like a virus :)
AFAIK, you must recompile wget as follows. 1. remove "_CONSOLE" from the CFLAGS. 2. replace main() with this: int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) and replace argc, argv with the globals __argc and __argv.
3. replace "/subsystem:console" with "/subsystem:windows" in the linker options.
Thank you very much.
Not sure 2. is needed.
I was suspecting that a main() to WinMain() change would do, but was cautious that would break things since lpCmdLine provides all arguments as a single string. I didn't know the global substitutes __argc and __argv existed -- I believe this was not so in older Microsoft compilers. Thanks!
Best regards, Vesko
_________________________________________________________________
MSN 8 with e-mail virus protection service: 2 months FREE* http://join.msn.com/?page=features/virus
