爲什麼下面的代碼總是打印出127(「指定的程序找不到」),即使它找到「firefox.exe」並終止它成功?GetLastError 127
#include<Windows.h>
#include <TlHelp32.h>
#include<iostream>
using namespace std;
int main(int, char *[])
{
PROCESSENTRY32 entry;
entry.dwSize = sizeof(PROCESSENTRY32);
HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);
if (Process32First(snapshot, &entry) == TRUE)
{
while (Process32Next(snapshot, &entry) == TRUE)
{
if (_tcscmp(entry.szExeFile, TEXT("firefox.exe")) == 0)
{
HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, entry.th32ProcessID);
DWORD d = GetLastError();
cout<<d<<'\n';
TerminateProcess(hProcess,0);
CloseHandle(hProcess);
}
}
}
CloseHandle(snapshot);
return 0;
}
'TerminateProcess()'沒有任何成功。它毫不費力地將它殺死。讓我們聽聽它的損壞的配置文件! – Deanna