//
bool CStudentComputerControl::FindProcess(CString ProcessName)
{
HANDLE handle=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
PROCESSENTRY32* info=new PROCESSENTRY32;
info->dwSize=sizeof(PROCESSENTRY32);
bool result=false;
if(Process32First(handle,info))
{
if(GetLastError()==ERROR_NO_MORE_FILES )
{
AfxMessageBox("No More Process");
result=false;
}
else
{
CString ProcessID,strProcessName;
ProcessID.Format("%d",info->th32ProcessID);
strProcessName.Format("%s",info->szExeFile);
while(Process32Next(handle,info)!=FALSE)
{
ProcessID.Format("%5d",info->th32ProcessID);
strProcessName.Format("%s",info->szExeFile);
if (!strProcessName.Compare(ProcessName))
{
result=true;
break;
}
}
}
}
CloseHandle(handle);
return result;
}
bool CStudentComputerControl::FindProcess(CString ProcessName)
{
HANDLE handle=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
PROCESSENTRY32* info=new PROCESSENTRY32;
info->dwSize=sizeof(PROCESSENTRY32);
bool result=false;
if(Process32First(handle,info))
{
if(GetLastError()==ERROR_NO_MORE_FILES )
{
AfxMessageBox("No More Process");
result=false;
}
else
{
CString ProcessID,strProcessName;
ProcessID.Format("%d",info->th32ProcessID);
strProcessName.Format("%s",info->szExeFile);
while(Process32Next(handle,info)!=FALSE)
{
ProcessID.Format("%5d",info->th32ProcessID);
strProcessName.Format("%s",info->szExeFile);
if (!strProcessName.Compare(ProcessName))
{
result=true;
break;
}
}
}
}
CloseHandle(handle);
return result;
}