BOOL Crar2Dlg::FindProcess(CString ProcessName) { HANDLE handle=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0); BOOL ret = FALSE; PROCESSENTRY32* info=new PROCESSENTRY32;//声明进程信息变量 info->dwSize=sizeof(PROCESSENTRY32); int i=0; if(Process32First(handle,info)) { if(GetLastError()==ERROR_NO_MORE_FILES ) return FALSE; else { CString id; id.Format(_T("%s"),info->szExeFile); if(ProcessName == id) ret = TRUE; if(ret == FALSE) { while(Process32Next(handle,info)!=FALSE) { id.Format(_T("%s"),info->szExeFile); if(id == ProcessName) { ret = TRUE; break; } i++; } } } } else ret = FALSE; CloseHandle(handle); delete info; return ret; }