首页 网络安全 安全学院 查看内容

获取系统进程代码实现

2009-11-9 13:44 658 0

摘要: #include "stdafx.h"    #include "windows.h"    #include "tlhe...
关键词: nbsp info HANDLE printf include PROCESSENTRY 32 ListProcess szExeFile ProcessID

#include "stdafx.h"    #include "windows.h"    #include "tlhelp32.h"    void ListProcess()    {            HANDLE handle=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);            PROCESSENTRY32* info=new PROCESSENTRY32;            info->dwSize=sizeof(PROCESSENTRY32);            int i=0;            if(Process32First(handle,info))            {                    if(GetLastError()==ERROR_NO_MORE_FILES )                    {                            printf("没有进程!");                    }                    else                   {                            printf("[PID] \t [进程名称] \n");                            //printf("%5d \t %s \n",info->th32ProcessID,info->szExeFile);                            i++;                            while(Process32Next(handle,info)!=FALSE)                            {                            printf("%5d \t %s \n",info->th32ProcessID,info->szExeFile);                            i++;                            }                    }            }            CloseHandle(handle);            delete info;    }       int main(int argc, char* argv[])    {            ListProcess();            return 0;    }  
声明:文章版权归原作者所有 部分文章转自互联网 如有侵权请联系 [邮箱地址] 删除

路过

雷人

握手

鲜花

鸡蛋

最新评论

返回顶部