看过这方面的代码
但本人是菜鸟,刚刚入门看不懂呀
不过看起来好像是要用到注册表
所以请各位大侠们帮一把
给我讲一下它的原理就可以了
如果有短一点的代码也可以(长的真晕啊)感激不尽

解决方案 »

  1.   

    http://www.vckbase.com/document/listdoc.asp?mclsid=13&sclsid=1305
      

  2.   

    void CShowAllProcessDlg::OnGetProcess() 
    {
    // TODO: Add your control notification handler code here
    HANDLE Snapshot;
    Snapshot=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
    //获得某一时刻系统的进程、堆(heap)、模块(module)或线程的快照信息
    PROCESSENTRY32 processListStr;
    processListStr.dwSize=sizeof(PROCESSENTRY32);
    BOOL return_value;
    return_value=Process32First(Snapshot,&processListStr);
    //获得系统进程链表中第一个进程的信息
    m_showlist.DeleteAllItems();
    int i=0;//item index
    while(return_value)
    {
    m_showlist.InsertItem(i,processListStr.szExeFile,0);
    CString s;
    s.Format("%d",processListStr.cntThreads);
    m_showlist.SetItemText(i,1,s);
    s.Format("%d",processListStr.th32ParentProcessID);
    m_showlist.SetItemText(i,2,s);
    s.Format("%d",processListStr.pcPriClassBase);
    m_showlist.SetItemText(i,3,s);

    int memory=processListStr.cntThreads;
    m_ProcessIndex[i]=processListStr.th32ProcessID;//save ID into array to teminate 
    return_value=Process32Next(Snapshot,&processListStr);
    //获得系统进程链表中下一个进程的信息
    i++;
    }}
      

  3.   

    #include <windows.h>
    #include <iostream.h>
    #include <conio.h>
    #include <tlhelp32.h>int main(int argc, char* argv[])
    {
    HANDLE hStdout=GetStdHandle(STD_OUTPUT_HANDLE);
    SetConsoleTextAttribute(hStdout,FOREGROUND_GREEN|FOREGROUND_INTENSITY);
    SetConsoleTitle("简易进程查看器");
    cout<<"按回车查看当前所有进程:"<<endl;
    int ch1;
    ch1=getche();
    if(ch1=='\r')
    {
    SetConsoleTextAttribute(hStdout,FOREGROUND_RED|FOREGROUND_BLUE|FOREGROUND_INTENSITY);
    HANDLE hSnapshot=::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
    PROCESSENTRY32 pe;
    ::ZeroMemory(&pe,sizeof(pe));
    pe.dwSize=sizeof(pe);
    BOOL bMore=::Process32First(hSnapshot,&pe);
    while(bMore)
    {
    HANDLE hProcess=::OpenProcess(PROCESS_QUERY_INFORMATION,FALSE,pe.th32ParentProcessID);
    cout<<"Process ID:"<<pe.th32ProcessID<<", Process Name:"<<pe.szExeFile<<endl;
    ::CloseHandle(hProcess);
    bMore=::Process32Next(hSnapshot,&pe);
    }
    }
    SetConsoleTextAttribute(hStdout,FOREGROUND_GREEN|FOREGROUND_INTENSITY);
    cout<<"\n按任意键退出:"<<endl;
    int ch2;
    ch2=getche();
    CloseHandle(hStdout);
    hStdout=NULL;
    return 0;
    }