#include <stdlib.h>
#include <stdio.h>
#include <windows.h>
#include <tlhelp32.h>
#include <iostream>
using namespace std;
int main(int argc,char **argv[]){
HANDLE m_hSnapshot = INVALID_HANDLE_VALUE;
PROCESSENTRY32 pe;
BOOL no;
char msg[100];
memset(&pe, 0, sizeof(pe));
pe.dwSize = sizeof(pe);
m_hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
no = Process32First(m_hSnapshot, &pe);
while(no){
sprintf(msg, "%S", pe.szExeFile);
cout<<msg<< " ID:"<< pe.th32ProcessID<<" thread:"<<pe.cntThreads<<endl;
no = Process32Next(m_hSnapshot, &pe);
}
CloseHandle(m_hSnapshot);
}
|