Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1092291
  • 博文数量: 284
  • 博客积分: 8223
  • 博客等级: 中将
  • 技术积分: 3188
  • 用 户 组: 普通用户
  • 注册时间: 2008-12-01 13:26
文章分类

全部博文(284)

文章存档

2012年(18)

2011年(33)

2010年(83)

2009年(147)

2008年(3)

分类: C/C++

2010-06-06 14:19:07

#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);
}


阅读(1180) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~