I recently have my program suddenly got a problem. My program needs to
spawn a process of XCOPY and then waits for it to terminate. The code
like this:
---------
STARTUPINFO si = {0};
si.cb = sizeof(STARTUPINFO);
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = SW_HIDE;
PROCESS_INFORMATION pi = {0};
CString str = "cmd /c XCOPY .....";
if (::CreateProcess(NULL, (LPSTR)(LPCSTR)str, NULL, NULL, FALSE,
NORMAL_PRIORITY_CLASS|CREATE_NO_WINDOW, NULL, lpszPath, &si, &pi))
{
switch (::WaitForSingleObject(pi.hProcess, 3600000))
{
case WAIT_OBJECT_0:
{
DWORD dwRet;
if (::GetExitCodeProcess(pi.hProcess, &dwRet))
{
...
}
}
break;
case WAIT_TIMEOUT:
...
break;
default:
break;
}
::CloseHandle(pi.hProcess);
}
------
The problem is:
"SOMETIMES", the dwRet from GetExitCodeProcess will be
STILL_ACTIVE(259). However, I found that the XCOPY command had been
successfully copied the files and the cmd prompt had been closed. The
problem happened randomly.
The problem happened recently.
Thanks in advance.
- tony.
Mattias Sj?gren - 29 Dec 2003 19:47 GMT
Tony,
I don't see how this is .NET related. I suggest you repost to the
appropriate group in the microsoft.public.win32.programmer.* or
microsoft.public.platformsdk.* hierarchy.
Mattias

Signature
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.