本文整理汇总了C++中Handle::IsValid方法的典型用法代码示例。如果您正苦于以下问题:C++ Handle::IsValid方法的具体用法?C++ Handle::IsValid怎么用?C++ Handle::IsValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Handle
的用法示例。
在下文中一共展示了Handle::IsValid方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetList
ThreadList Thread::GetList(UInt32 processId)
{
Handle hSnapshot = ::CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, processId);
if (!hSnapshot.IsValid())
{
THROW_LAST_ERROR_EXCEPTION();
}
THREADENTRY32 threadEntry = {0};
threadEntry.dwSize = sizeof(threadEntry);
BOOL success = ::Thread32First(hSnapshot, &threadEntry);
if (!success)
{
THROW_LAST_ERROR_EXCEPTION();
}
ThreadList list;
while (success)
{
if (threadEntry.th32OwnerProcessID == processId)
{
list.push_back(Thread(threadEntry.th32ThreadID));
}
success = ::Thread32Next(hSnapshot, &threadEntry);
}
return list;
}
示例2: GetFilePath
String Process::GetFilePath(UInt32 processId)
{
Handle hModuleSnap = ::CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, processId);
if (hModuleSnap.IsValid())
{
MODULEENTRY32 moduleEntry = {0};
moduleEntry.dwSize = sizeof(moduleEntry);
if (::Module32First(hModuleSnap, &moduleEntry))
{
//
// Native processes on Windows XP are known to have weird paths
//
return FileSystem::Path::NtToWin32(moduleEntry.szExePath, False);
}
}
return String();
}
示例3: GetModuleList
ProcessModuleList Process::GetModuleList() const
{
Handle hModuleSnap = ::CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, m_id);
if (hModuleSnap.IsValid())
{
MODULEENTRY32 moduleEntry = { 0 };
moduleEntry.dwSize = sizeof(moduleEntry);
if (!::Module32First(hModuleSnap, &moduleEntry))
return ProcessModuleList();
ProcessModuleList moduleList;
do
{
moduleList.push_back(moduleEntry.szExePath);
}
while (::Module32Next(hModuleSnap, &moduleEntry));
return std::move(moduleList);
}
return ProcessModuleList();
}
示例4: GetList
ProcessList Process::GetList()
{
Handle hSnapshot = ::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (!hSnapshot.IsValid())
{
THROW_LAST_ERROR_EXCEPTION();
}
PROCESSENTRY32 processEntry = {0};
processEntry.dwSize = sizeof(processEntry);
BOOL success = ::Process32First(hSnapshot, &processEntry);
if (!success)
{
THROW_LAST_ERROR_EXCEPTION();
}
ProcessList list;
while (success)
{
#ifdef _DEBUG
//if (_wcsicmp(processEntry.szExeFile, L"winword.exe") == 0 ||
// _wcsicmp(processEntry.szExeFile, L"iexplore.exe") == 0 ||
// wcscmp(processEntry.szExeFile, L"firefox.exe") == 0 ||
// wcsncmp(processEntry.szExeFile, L"FlashPlayerPlugin", 17) == 0 ||
// wcscmp(processEntry.szExeFile, L"AccessEnum.exe") == 0 ||
// wcscmp(processEntry.szExeFile, L"TSVNCache.exe") == 0 ||
// wcscmp(processEntry.szExeFile, L"plugin-container.exe") == 0)
#endif
list.push_back(Process(
processEntry.th32ProcessID,
processEntry.th32ParentProcessID,
processEntry.szExeFile));
success = ::Process32Next(hSnapshot, &processEntry);
}
return list;
}
示例5: IsStillActive
Bool Process::IsStillActive() const
{
Handle handle = ::OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, m_id);
if (!handle.IsValid())
{
THROW_LAST_ERROR_EXCEPTION();
}
DWORD exitCode = 0;
BOOL success = ::GetExitCodeProcess(handle, &exitCode);
if (!success)
{
THROW_LAST_ERROR_EXCEPTION();
}
if (STILL_ACTIVE == exitCode)
{
return True;
}
return False;
}