十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
#include"tlhelp32.h" DWORD GetProcessIdFromName(LPCWSTR name) { PROCESSENTRY32 pe; DWORD id = 0; HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); pe.dwSize = sizeof(PROCESSENTRY32); if (!Process32First(hSnapshot, &pe)) return 0; while (1) { pe.dwSize = sizeof(PROCESSENTRY32); if (Process32Next(hSnapshot, &pe) == FALSE) break; if (wcscmp(pe.szExeFile, name) == 0) { id = pe.th42ProcessID; break; } } CloseHandle(hSnapshot); return id; } void CMFCApplication1Dlg::OnBnClickedButton27() { INT ret = GetProcessIdFromName(_T("notepad.exe") );//获取记事本的进程ID }