#include <afx.h> #include <Tlhelp32.h> int killpro(CString a) { PROCESSENTRY32 pe32; pe32.dwSize =sizeof(pe32); HANDLE hpro=::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0); if(hpro==INVALID_HANDLE_VALUE ) { return 0; } BOOL nowrun=Process32First(hpro,&pe32); while(nowrun) { if(pe32.szExeFile ==a) { DWORD proid=pe32.th32ProcessID; HANDLE hprocess=::OpenProcess(PROCESS_ALL_ACCESS,FALSE,proid); if(hprocess!=NULL) { ::TerminateProcess(hprocess,0); ::CloseHandle(hprocess); } } nowrun=::Process32Next(hpro,&pe32); } }