CreateProcess succeeds, but GetLastError() returns access denied
由于
如果访问被拒绝,为什么它会完成任务。 相反,如果
还是我对
1 2 3 4 5 6 7 8 9 10 | SetLastError(0); hello = CreateProcess(_T("C:\\\\Windows\\\\System32\\\\cmd.exe"), _T("C:\\\\Windows\\\\System32\\\\cmd.exe /C ant debug"), NULL,NULL,false,0,NULL, _T("C:\\\\My\\\\Directory"),&siStartupInfo, &piProcessInfo); FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |FORMAT_MESSAGE_ALLOCATE_BUFFER |FORMAT_MESSAGE_IGNORE_INSERTS,NULL,GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&errorText, 0, NULL); AfxMessageBox(errorText); |
这种行为正常吗? 在
无论
从
The Return Value section of the documentation for each function that sets the last-error code notes the conditions under which the function sets the last-error code. Most functions that set the thread's last-error code set it when they fail. However, some functions also set the last-error code when they succeed. [emphasis mine]
我认为您得到了有经验的结果,因为成功完成
据记录,