w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Accessing CPU/RAM usage (like with Task Manager, but via API!)?

You can use the following Windows API to reterive various process counters in C/C++ program. It retrieves information about the memory usage of the specified process.

BOOL WINAPI GetProcessMemoryInfo(
  _In_   HANDLE Process,
  _Out_  PPROCESS_MEMORY_COUNTERS ppsmemCounters,
  _In_   DWORD cb

There is complete example on MSDN, which explains how it can be used to retrieve such information for your process.


You have mentioned that you would like to fetch the information on continuous basis(with some time interval as task manager do). To achieve this you may want to write the complete logic(mentioned in MSDN) inside a function and call it after some time delay(Sleep(1second)).This way you should be able to fetch all these information of your program till it executes.

© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.