bool ChildProcessManager::IsChildProcessAvailable()
{
	if (IsChildProcessCreated())
	{
		CProcessIterator itp;
		for (DWORD pid = itp.First(); pid; pid = itp.Next()) {
			if (pid == m_piProcInfo->dwProcessId)
			{
				return true;
			}
		}
	}
	return false;
}
示例#2
0
//////////////////
// Search for process whose module name matches parameter.
// Finds "foo" or "foo.exe"
//
DWORD CFindKillProcess::FindProcess(LPCTSTR modname, BOOL bAddExe)
{
	CProcessIterator itp;
	for (DWORD pid=itp.First(); pid; pid=itp.Next()) 
	{
		TCHAR name[_MAX_PATH];
		CProcessModuleIterator itm(pid);
		HMODULE hModule = itm.First(); // .EXE
		if (hModule) 
		{
			GetModuleBaseName(itm.GetProcessHandle(),
				hModule, name, _MAX_PATH);
			
			string sModName = modname;
			if (strcmpi(sModName.c_str(),name)==0)
				return pid;
			sModName += ".exe";
			if (bAddExe && strcmpi(sModName.c_str(),name)==0)
				return pid;
		}
	}
	return 0;
}