CreateProcess SW_HIDE not working
Ive been reading many many other articles on this issue and playing
with variations of
my code to get it working and cannot seem to get it to work. I have a
thread that is launched
withing a MFC GUI application which Im trying to silently do work in.
Im using wget.exe which
works fine. In fact all the code works great except the stupid window
keeps popping up everytime
it launches my wget. I even tried to reduce the size of the window to
1 x 1 pixels and that
doesnt even work!
Can someone tell me why? Ive looked at the microsoft pages on article
Q150956 and anything
else I could see with no luck.
I appreciate it!
Relevant code here:
DWORD WINAPI myThreadFunc(LPVOID lpParam )
{
char cmd[255];
char ipfile[255];
char buf[25];
BOOL m_run = true;
while (m_run)
{
sprintf(ipfile, "C:\\bin\\myip.txt");
sprintf(cmd, "C:\\bin\\wget -q -nv http://10.10.10.1/cgi-bin/getip.cgi
-O %s", ipfile);
STARTUPINFO si;
ZeroMemory(&si, sizeof(si));
//GetStartupInfo(&si);
si.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESIZE;
si.wShowWindow = SW_HIDE;
si.dwXSize = 1;
si.dwYSize = 1;
si.cb = sizeof(si); // Must set the size of structure
PROCESS_INFORMATION pi;
BOOL ret = CreateProcess(NULL, cmd, NULL, NULL, FALSE,
CREATE_NO_WINDOW, // | DETACHED_PROCESS,
NULL, NULL, &si, &pi);
if (ret)
{
WaitForSingleObject(pi.hProcess, 1000 * 2); // wait 2 seconds
CloseHandle(pi.hProcess);
}
Sleep(1000 * 5);
}
return 0;
}