//查CSDN以前的贴子比在CSDN上再问一次快!!!!!!!!!!!!!!
切记

解决方案 »

  1.   

    再贴一次
    (太累了,不过可能会再得分,那就贴吧)编号  主  题 来 源 收录时间 
    1 列举进程及相关信息 自撰 00.05.08 
    列举进程、线程、堆、模块等。 
    一、列出进程 
    //列出所有进程
    HANDLE snapshothandle=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
    PROCESSENTRY32 processentry;
    processentry.dwSize=sizeof(PROCESSENTRY32);
    BOOL finded=Process32First(snapshothandle,&processentry);
    while(finded!=NULL)
    {
        //processentry中返回进程信息
        finded=Process32Next(snapshothandle,&processentry);
    }
    CloseHandle(snapshothandle);
    二、列出线程 
    //列出所有线程
    HANDLE snapshothandle=CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD,0);
    THREADENTRY32 threadentry;
    threadentry.dwSize=sizeof(THREADENTRY32);
    BOOL finded=Thread32First(snapshothandle,&threadentry);
    while(finded!=NULL)
    {
        //threadentry中返回线程信息        
        finded=Thread32Next(snapshothandle,&threadentry);
    }
    CloseHandle(snapshothandle);
    三、列出模块 
    //列出指定进程调用到的DLL等。
    //pid为进程ID
    HANDLE snapshothandle=CreateToolhelp32Snapshot(TH32CS_SNAPMODULE,pid);
    MODULEENTRY32 moduleentry;
    moduleentry.dwSize=sizeof(MODULEENTRY32);
    finded=Module32First(snapshothandle,&moduleentry);
    while(finded!=NULL)
    {
        //moduleentry中返回模块信息
        finded=Module32Next(snapshothandle,&moduleentry);
    }
    CloseHandle(snapshothandle);
    三、列出进程分配的内存(堆) 
    //先得到堆表
    //再列出堆
    //pid为进程ID
    HANDLE snapshothandle=CreateToolhelp32Snapshot(TH32CS_SNAPHEAPLIST,pid);
    HEAPLIST32 heaplistentry;
    heaplistentry.dwSize=sizeof(HEAPLIST32);
    finded=Heap32ListFirst(snapshothandle,&heaplistentry);
    while(finded!=NULL)
    {
        //heaplistentry中返回了堆表的信息
        
        
        //列出堆表中的的堆
        HEAPENTRY32 heapentry;
        heapentry.dwSize=sizeof(HEAPENTRY32);
        //heaplistentry.th32HeapID为堆ID
        BOOL finded2=Heap32First(&heapentry,pid,heaplistentry.th32HeapID);
        while(finded2!=NULL)
        {
            //heapentry中返回堆信息
            finded2=Heap32Next(&heapentry);
        }    finded=Heap32ListNext(snapshothandle,&heaplistentry);
    }
    CloseHandle(snapshothandle);