新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
檢查進(jìn)程是否運(yùn)行
#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") );//獲取記事本的進(jìn)程ID }
文章名稱:檢查進(jìn)程是否運(yùn)行
瀏覽路徑:http://www.ef60e0e.cn/article/peegei.html