Solved

find a C++ program to get information that is shown in a 'Task Manager' performance window

Posted on 2010-09-08
6
383 Views
Last Modified: 2013-12-04
I need to write a C++ program to monitor what is currently available memory, how much cpu time is used and other information shown in Windows 'Task Manager'. Any clue?
0
Comment
Question by:Ziren
6 Comments
 
LVL 65

Expert Comment

by:rockiroads
ID: 33632057
0
 
LVL 33

Expert Comment

by:pgnatyuk
ID: 33635093
GlobalMemoryStatus/GlobalMemoryStatusEx to detect the memory:
http://msdn.microsoft.com/en-us/library/aa366589(VS.85).asp
There is an example.

GetProcessTimes gives a time information about processes - how long the process is running:
http://msdn.microsoft.com/en-us/library/ms683223(VS.85).asp

If you need to collect the performance data, you may use PdhOpenQuery,etc. Here is an example:
MSDN. Writing Performance Data to a Log File
http://msdn.microsoft.com/en-us/library/aa373228(VS.85).asp

You can find a lot in MSDN:
Performance Monitoring
http://msdn.microsoft.com/en-us/library/ee663292(v=VS.85).asp
You can download Process Explorer from Microsoft SysInternals:
http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx

Check this CodeProject article: Process viewer
http://www.codeproject.com/KB/cpp/processviewer.aspx
Maybe, here is everything you are looking for.
0
 
LVL 1

Expert Comment

by:XMarshall10
ID: 33635777
To get you started, you can start your project by Enumerating all the process running in your local system by using Win32 API's like EnumProcesses. List all the process in a window.

Then refer to the above links provided by the other experts for gathering further information's like memory, cpu time, etc.

--XM
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Accepted Solution

by:
Ziren earned 0 total points
ID: 33638816
thanks very much for you guy's inputs, now I have one question solved on how to get memory usage information. I tried the method at 'http://www.codeproject.com/KB/system/MultiCPUUsage.aspx' to get cpu usage but failed, When run the program, there is no error message, but cpu usage is always 0. Is there other way to get this information?
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 33639694
try this http://www.cplusplus.com/forum/windows/14580/ - tweaked version after initial post
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 33758990
So what did you do to solve it?
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

867 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

20 Experts available now in Live!

Get 1:1 Help Now