Solved

CPU Usage and Memory Usage

Posted on 1998-06-29
7
867 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
0
Comment
Question by:prashantp
  • 3
  • 2
  • 2
7 Comments
 
LVL 2

Expert Comment

by:rayb
Comment Utility
Check the VC Documentation for functions like GetProcess????.  i.e. GetProcessHeap and GetProcessWorkingSetSize



0
 

Author Comment

by:prashantp
Comment Utility
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.
0
 
LVL 2

Expert Comment

by:rayb
Comment Utility
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;

0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:prashantp
Comment Utility
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 ?
0
 
LVL 4

Expert Comment

by:piano_boxer
Comment Utility
Is this for NT or 95(98) ?

If its for NT, you can get all the information you need (performance counters) from the registry.
0
 
LVL 4

Accepted Solution

by:
piano_boxer earned 50 total points
Comment Utility
Heres complete articles and source code about performance counters in windows NT:

http://www.eu.microsoft.com/msj/0598/hood0598.htm
0
 

Author Comment

by:prashantp
Comment Utility

thanks piano_boxer

i got all i needed in that url.

thank you once again.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now