Список процессов.
Только типы поправь.
C++ (Qt)
/***************************************************************************/
class LProcessInfo {
public:
LProcessInfo() {
memset( &pi, 0, sizeof(PROCESSENTRY32) );
}
LProcessInfo( PROCESSENTRY32 p ) {
memset( &pi, 0, sizeof(PROCESSENTRY32) );
init(p);
}
~LProcessInfo() { }
/**/
void init( PROCESSENTRY32 p ) { memcpy( &pi, &p, sizeof(PROCESSENTRY32) ); }
/**/
luint32 id() const { return pi.th32ProcessID; }
luint32 size() const { return pi.dwSize; }
luint32 usage() const { return pi.cntUsage; }
luint32 module_id() const { return pi.th32ModuleID; }
luint32 threads() const { return pi.cntThreads; }
luint32 parent_id() const { return pi.th32ParentProcessID; }
lint32 parent_pri() const { return pi.pcPriClassBase; }
luint32 flags() const { return pi.dwFlags; }
const lchar*name() const { return &pi.szExeFile[0]; }
/**/
bool operator< ( const LProcessInfo& pi ) {
return l_strcmpi( name(), pi.name() ) < 0;
}
private:
PROCESSENTRY32 pi;
};
/***************************************************************************/
class LProcessInfoList: public LVector<LProcessInfo> {
public:
LProcessInfoList() { refresh(); }
~LProcessInfoList() {}
/**/
void refresh() {
HANDLE pl;
PROCESSENTRY32 pe;
/**/
pl = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
pe.dwSize = sizeof(PROCESSENTRY32);
pe.th32ParentProcessID = 0;
/**/
if ( Process32First(pl, &pe) ) {
do {
push_back( LProcessInfo(pe) );
pe.th32ParentProcessID = 0;
} while ( Process32Next(pl, &pe) );
}
CloseHandle(pl);
}
};
/***************************************************************************/