获取进程列表
2009-08-24 17:37
513 查看
BOOL GetProcessList( )
{
HANDLE hProcessSnap;
HANDLE hProcess;
PROCESSENTRY32 pe32;
DWORD dwPriorityClass;
// Take a snapshot of all processes in the system.
hProcessSnap = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
if( hProcessSnap == INVALID_HANDLE_VALUE )
{
printError( _T("CreateToolhelp32Snapshot (of processes)") );
return( FALSE );
}
// Set the size of the structure before using it.
pe32.dwSize = sizeof( PROCESSENTRY32 );
// Retrieve information about the first process,
// and exit if unsuccessful
if( !Process32First( hProcessSnap, &pe32 ) )
{
printError( _T("Process32First") ); // Show cause of failure
CloseHandle( hProcessSnap ); // Must clean up the
// snapshot object!
return( FALSE );
}
// Now walk the snapshot of processes, and
// display information about each process in turn
do
{
printf( "\n\n"
"=====================================================" );
wprintf( _T("\nPROCESS NAME: %s"), pe32.szExeFile );
printf( "\n"
"-----------------------------------------------------" );
} while( Process32Next( hProcessSnap, &pe32 ) );
CloseHandle( hProcessSnap );
return( TRUE );
}
{
HANDLE hProcessSnap;
HANDLE hProcess;
PROCESSENTRY32 pe32;
DWORD dwPriorityClass;
// Take a snapshot of all processes in the system.
hProcessSnap = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
if( hProcessSnap == INVALID_HANDLE_VALUE )
{
printError( _T("CreateToolhelp32Snapshot (of processes)") );
return( FALSE );
}
// Set the size of the structure before using it.
pe32.dwSize = sizeof( PROCESSENTRY32 );
// Retrieve information about the first process,
// and exit if unsuccessful
if( !Process32First( hProcessSnap, &pe32 ) )
{
printError( _T("Process32First") ); // Show cause of failure
CloseHandle( hProcessSnap ); // Must clean up the
// snapshot object!
return( FALSE );
}
// Now walk the snapshot of processes, and
// display information about each process in turn
do
{
printf( "\n\n"
"=====================================================" );
wprintf( _T("\nPROCESS NAME: %s"), pe32.szExeFile );
printf( "\n"
"-----------------------------------------------------" );
} while( Process32Next( hProcessSnap, &pe32 ) );
CloseHandle( hProcessSnap );
return( TRUE );
}
相关文章推荐
- Android 获取进程列表
- 获取进程、服务、任务列表
- 枚举PEB获取进程模块列表
- 【Demo 0076】获取进程中模块列表
- 如何获取linux下的进程pid列表
- 获取进程列表
- 获取windows进程列表,并以字符串形式查询是否存在某一进程
- 几种获取进程列表的方法
- 枚举PEB获取进程模块列表
- 获取进程、服务、任务列表
- VC获取系统进程列表、查找进程、关闭进程
- android 获取进程、服务、任务列表
- windows 获取进程列表的几种方式
- Java获取进程列表的方法
- 获取系统中的进程列表(win 32 SDK)
- 获取进程列表和结束进程
- 获取进程、服务、任务列表
- 几种获取进程列表的方法
- 获取进程列表和模块信息
- C# 获取系统当前进程列表 浮兮 视频解析