白衣非少年
#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调用失败! \n");return -1;}BOOL bMore = ::Process32First(hProcessSnap, &pe32);while(bMore){if(strcat(pe32.szExeFile,"你的进程名")==0){printf(" 进程ID号:%u \n\n", pe32.th32ProcessID);break;} bMore = ::Process32Next(hProcessSnap, &pe32);}printf(" 没有找到进程");::CloseHandle(hProcessSnap);return 0;}