本文整理汇总了C++中Process::SetProcessEntry32方法的典型用法代码示例。如果您正苦于以下问题:C++ Process::SetProcessEntry32方法的具体用法?C++ Process::SetProcessEntry32怎么用?C++ Process::SetProcessEntry32使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Process
的用法示例。
在下文中一共展示了Process::SetProcessEntry32方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Enumerate
/**
*
* Enumerates and maintains a list of processes running in a system.
*
* @param Nil
* @return bool - Returns execution status.
* @exception Nil
* @see Nil
* @since 1.0
*/
bool ProcessCollection::Enumerate()
{
// Clear previous information
Clear();
// Process snapshot
HANDLE hProcessSnap = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
if( hProcessSnap == INVALID_HANDLE_VALUE )
{
ASSERT( FALSE );
return false;
}
// Auto close handle
Utils::AutoHandleMgr ahmHandleMgr( hProcessSnap );
// Process entry structure
PROCESSENTRY32 stpePrcEntry32 = { 0 };
stpePrcEntry32.dwSize = sizeof( stpePrcEntry32 );
// Get first process
if( !Process32First( hProcessSnap, &stpePrcEntry32 ))
{
ASSERT( FALSE );
return false;
}
// Get process ids of all running processes
DWORD dwRealProcessCount = 0;
// Loop through and get each process
do
{
// Increment process count
++dwRealProcessCount;
// Allocate new process
Process* pNewProcess = new Process;
if( !pNewProcess )
{
return false;
}
// Set process information
pNewProcess->SetProcessEntry32( stpePrcEntry32 );
// Process information
Process* pParentProcess = 0;
if( m_mapProcesses.Lookup( stpePrcEntry32.th32ParentProcessID, pParentProcess ) && pParentProcess )
{
pParentProcess->AddKid( pNewProcess );
}
else
{
// Since this process doesn't have a parent we will add this to super process list
m_lstSuperProcesses.AddTail( pNewProcess );
}// End if
// Insert this process to map
m_mapProcesses[stpePrcEntry32.th32ProcessID] = pNewProcess;
}while( Process32Next( hProcessSnap, &stpePrcEntry32 ));
// Set count of loaded processes
SetProcessCount( dwRealProcessCount );
// Return success
return true;
}