1)我用 ShellExecuteEx 启动了一个进程
2)检索PID
GetProcessId(shellExInfo.hProcess)
示例代码:
SHELLEXECUTEINFO shellExInfo;
shellExInfo.cbSize = sizeof(SHELLEXECUTEINFO);
shellExInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
shellExInfo.hwnd = NULL;
shellExInfo.lpVerb = "open";
shellExInfo.lpFile = processToStart.c_str();
shellExInfo.lpParameters = processParams.c_str();
shellExInfo.lpDirectory = NULL;
shellExInfo.nShow = SW_SHOW;
shellExInfo.hInstApp = NULL;
ShellExecuteEx(&shellExInfo); // start process
GetProcessId(shellExInfo.hProcess); // retrieve PID
现在我想用给定的 PID 杀死启动的进程!这怎么可能?
谢谢