15,471
社区成员
发帖
与我相关
我的任务
分享
BOOL GetProcessID(LPCTSTR lpsz)
{
CString strExeName(lpsz);
strExeName.MakeLower();
HANDLE handle=::CreateToolhelp32Snapshot(TH32CS_SNAPALL,0);
PROCESSENTRY32 Info ;
Info.dwSize = sizeof(PROCESSENTRY32);
if(::Process32First(handle,&Info))
{
while(::Process32Next(handle,&Info)!=FALSE)
{
CString ss;
ss=Info.szExeFile;
ss.MakeLower();
if(ss.Compare(strExeName)==0)
{
#ifdef WINCE_HD
CloseToolhelp32Snapshot(handle);
#else
CloseHandle(handle);
#endif
return Info.th32ProcessID;
}
}
#ifdef WINCE_HD
CloseToolhelp32Snapshot(handle);
#else
CloseHandle(handle);
#endif
return FALSE;
}
}