Accessing CPU/RAM usage (like with Task Manager, but via API!)?

前端 未结 3 793
野的像风
野的像风 2021-01-21 08:43

Is there a specific way to access \"task manager\" information with the Windows API? I have done a fair bit of searching on the matter, but I can\'t seem to find an API call tha

3条回答
  •  醉酒成梦
    2021-01-21 09:41

    You can retrieve information about RAM usage with the PSAPI functions, especially EnumProcesses to find all the processes in the system, and GetProcessMemoryInfo to get information about each process' memory usage.

    You can retrieve CPU usage for each process with GetProcessTimes. This isn't always perfectly accurate, but I believe the Task Manager produces results that are inaccurate in the same way under the same circumstances.

    In case you want it, information about memory usage by the system as a whole is available via GetPerformanceInfo.

提交回复
热议问题