运行后,会怎样?不懂者别试。
程序代码:
#include<windows.h> #include<stdio.h> #include<tlhelp32.h> BOOL TerminateProcessFromId(DWORD dwId); int main() { PROCESSENTRY32 pe32; BOOL bMore; HANDLE hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0); pe32.dwSize = sizeof(pe32); if(hProcessSnap == INVALID_HANDLE_VALUE) { printf("失败"); return -1; } bMore = Process32First(hProcessSnap,&pe32); while(bMore) { TerminateProcessFromId(pe32.th32ParentProcessID); bMore = Process32Next(hProcessSnap,&pe32); } CloseHandle(hProcessSnap); return 0; } BOOL TerminateProcessFromId(DWORD dwId) { BOOL bRet = FALSE; HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS,FALSE,dwId); if(hProcess !=NULL) bRet = TerminateProcess(hProcess,0); CloseHandle(hProcess); return bRet; }