DWORD 进程_名取ID(CString 进程名)
DWORD 进程_名取ID(CString 进程名) { HANDLE 进程快照 = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); if (INVALID_HANDLE_VALUE == 进程快照) { return NULL; } PROCESSENTRY32 进程信息 = { sizeof(进程信息) }; for (BOOL ret = Process32First(进程快照, &进程信息); ret; ret = Process32Next(进程快照, &进程信息)) { if (strcmp(进程信息.szExeFile, 进程名) == 0) { CloseHandle(进程快照); return 进程信息.th32ProcessID; } } CloseHandle(进程快照); return 0; }