We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

CPU Usage and Memory Usage

prashantp
prashantp asked
on
Medium Priority
935 Views
Last Modified: 2013-11-20
Pl tell me how to get CPU usage and Memory usage (as show in the Task Manager) in my MFC
application
Comment
Watch Question

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



Author

Commented:
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.

Commented:
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;

Author

Commented:
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.
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview

Author

Commented:

thanks piano_boxer

i got all i needed in that url.

thank you once again.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.