#include <iostream>
#include <Windows.h>
using std::cout;
using std::endl;
using std::cin;
int main()
{
cout << "1." << GetLastError() << endl;
PROCESS_INFORMATION processInfo;
STARTUPINFOA startupInfo = {0};
CONTEXT context;
context.ContextFlags = CONTEXT_FULL;
cout << "3." << GetLastError() << endl;
if (CreateProcess((PCHAR)"rsclient.exe", NULL, NULL, NULL, false, CREATE_SUSPENDED, NULL, NULL, &startupInfo, &processInfo) == false) {
cout << "CreateProcess error: " << GetLastError() << endl;
}
cout << "4." << GetLastError() << endl;
if (GetThreadContext(processInfo.hProcess, &context) == false) {
cout << "GetThreadContext error:" << GetLastError() << endl;
}
return 0;
}
输出:
1.2
3.2
4.1813
GetThreadContext error:6
我可以在任务管理器中看到暂停的进程,但我得到一个无效的句柄错误?
另外为什么 GetLastError() 在程序开始时给出 ERROR_FILE_NOT_FOUND ?