1 回答

TA貢獻(xiàn)1155條經(jīng)驗 獲得超0個贊
#include "stdafx.h"
#include <windows.h>
#include <tlhelp32.h> int main(int argc, char* argv[])
{
PROCESSENTRY32 pe32;
pe32.dwSize = sizeof(pe32);
HANDLE hProcessSnap = ::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if(hProcessSnap == INVALID_HANDLE_VALUE)
{
printf(" CreateToolhelp32Snapshot調(diào)用失?。?\n");
return -1;
}
BOOL bMore = ::Process32First(hProcessSnap, &pe32);
while(bMore)
{if(strcat(pe32.szExeFile,"你的進(jìn)程名")==0){printf(" 進(jìn)程ID號:%u \n\n", pe32.th32ProcessID);break;} bMore = ::Process32Next(hProcessSnap, &pe32);
}printf(" 沒有找到進(jìn)程");
::CloseHandle(hProcessSnap);
return 0;
}
添加回答
舉報