//判断进程id是否存在 //@param:process_id:需要传入的进程id值 //return:True:存在,False:不存在 BOOL isExistProcess(DWORD process_id) { HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); if (INVALID_HANDLE_VALUE == hSnapshot) { return NULL; } PROCESSENTRY32 pe = { sizeof(pe) }; for (BOOL ret = Process32First(hSnapshot, &pe); ret; ret = Process32Next(hSnapshot, &pe)) { if (pe.th32ProcessID == process_id) { return TRUE; } } CloseHandle(hSnapshot); return FALSE; }