Link to home
Start Free TrialLog in
Avatar of prashantp
prashantp

asked on

CPU Usage and Memory Usage

Pl tell me how to get CPU usage and Memory usage (as show in the Task Manager) in my MFC
application
Avatar of rayb
rayb

Check the VC Documentation for functions like GetProcess????.  i.e. GetProcessHeap and GetProcessWorkingSetSize



Avatar of prashantp

ASKER

The GetProcessWorkingSetSize function obtains the minimum and maximum working set sizes of a specified process.
And I need the overall system's memory usage (physical + virtual )and cpu usage, as displayed by the Task Manager.
Heck, I'll try again...
Check out the WIN32 GlobalMemoryStatus function.  It returns the following structure:

typedef struct _MEMORYSTATUS { // mst
    DWORD dwLength;        // sizeof(MEMORYSTATUS)
    DWORD dwMemoryLoad;    // percent of memory in use
    DWORD dwTotalPhys;     // bytes of physical memory
    DWORD dwAvailPhys;     // free physical memory bytes
    DWORD dwTotalPageFile; // bytes of paging file
    DWORD dwAvailPageFile; // free bytes of paging file
    DWORD dwTotalVirtual;  // user bytes of address space
    DWORD dwAvailVirtual;  // free user bytes
} MEMORYSTATUS, *LPMEMORYSTATUS;

Well  rayb,

i tried the GlobalMemoryStatus function but the value it returned is different from that of the memory usage shown in the Task Manager.

And how about the CPU usage ?
Is this for NT or 95(98) ?

If its for NT, you can get all the information you need (performance counters) from the registry.
ASKER CERTIFIED SOLUTION
Avatar of piano_boxer
piano_boxer

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial

thanks piano_boxer

i got all i needed in that url.

thank you once again.