查找指定进程:
1 BOOL Test::FindProcess(const CString &sProcessName)
2 {
3 BOOL bResult = FALSE;
4 HANDLE handle = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);//
5 //PROCESSENTRY32 *info = new PROCESSENTRY32;
6 //info->dwSize=sizeof(PROCESSENTRY32);
7
8 PROCESSENTRY32 info;
9 info.dwSize = sizeof(PROCESSENTRY32);
10 Process32First(handle, &info);
11 while (Process32Next(handle, &info) != FALSE)
12 {
13 if (sProcessName.CompareNoCase(info.szExeFile) == 0)
14 {
15 bResult = TRUE;
16 break;
17 }
18 }
19 CloseHandle(handle);
20
21 return bResult;
22 }
posted on 2012-05-10 14:20
王海光 阅读(1068)
评论(0) 编辑 收藏 引用 所属分类:
MFC