各位大侠:
    如何在VC++开发平台下得到Windows系统CPU的占用率和内存的使用情况,
就像“任务管理”下动态呈现的数据一样,有相应的API函数吗?谢谢!

解决方案 »

  1.   

    可以
    GetSystemInfo取得与底层硬件平台有关的信息
    可以看看这里的一些api
    http://www.dapha.net/api/
    硬件与系统函数里面
      

  2.   

    关于内存的绝大多数信息可以通过以下函数获得:BOOL GetProcessMemoryInfo(
      HANDLE Process,                          // handle to process
      PPROCESS_MEMORY_COUNTERS ppsmemCounters, // buffer
      DWORD cb                                 // size of buffer
    );The GetProcessMemoryInfo function retrieves information about the memory usage of the specified process in the PROCESS_MEMORY_COUNTERS structure.typedef struct _PROCESS_MEMORY_COUNTERS {
        DWORD cb;
        DWORD PageFaultCount;
        SIZE_T PeakWorkingSetSize;
        SIZE_T WorkingSetSize;
        SIZE_T QuotaPeakPagedPoolUsage;
        SIZE_T QuotaPagedPoolUsage;
        SIZE_T QuotaPeakNonPagedPoolUsage;
        SIZE_T QuotaNonPagedPoolUsage;
        SIZE_T PagefileUsage;
        SIZE_T PeakPagefileUsage;
    } PROCESS_MEMORY_COUNTERS;
    typedef PROCESS_MEMORY_COUNTERS *PPROCESS_MEMORY_COUNTERS;
      

  3.   

    获得cpu时间:
    BOOL GetProcessTimes(
      HANDLE hProcess,           // handle to process
      LPFILETIME lpCreationTime, // process creation time
      LPFILETIME lpExitTime,     // process exit time
      LPFILETIME lpKernelTime,   // process kernel-mode time
      LPFILETIME lpUserTime      // process user-mode time
    );关于io信息:
    BOOL GetProcessIoCounters(
      HANDLE hProcess,           // handle to process
      PIO_COUNTERS lpIoCounters  // I/O accouting information
    );
      

  4.   

    http://expert.csdn.net/Expert/topic/2309/2309423.xml?temp=.0920679
    http://expert.csdn.net/Expert/topic/2319/2319630.xml?temp=.694729
    http://expert.csdn.net/Expert/topic/2309/2309423.xml?temp=.0920679