Valhalla Legends Archive

Programming => General Programming => Topic started by: DVX on January 25, 2004, 10:39 PM

Title: system statistics
Post by: DVX on January 25, 2004, 10:39 PM
how would i go about creating a relatively small program which gets some system statistics such as uptime, memory usage, cpu usage, etc.  are there any particular functions which can do this all?

the main things i want to beable to do are:  uptime, cpu usage, and memory usage..  i know you can find out most of this by ctrl + alt + del on winxp, but i use win98, and can't do that..  so that's one reason i want to make a program for this, and also a few other things..

anyone have any ideas?
Title: Re:system statistics
Post by: Grok on January 25, 2004, 11:03 PM
Yes, and I'm not attempting to be smart or funny.  Get rid of Win98 and get WinXP.
Title: Re:system statistics
Post by: DVX on January 25, 2004, 11:10 PM
i'm reformatting in a few days, win98 just came with the system, so it's just temporary..

but i still want to make a program that gets that information;  something like skywing's high resolution uptime program..
Title: Re:system statistics
Post by: iago on January 26, 2004, 07:00 AM
I'm going to hazard to guess you're using vb.  Add an about form to your project (one of the premade forms) and then run the program and click "System Info".
Title: Re:system statistics
Post by: DVX on January 26, 2004, 02:14 PM
c++ :P

but i did find something in regards to the system uptime statistic..  i used GetTickCount() function from the windows api..  basically, i did a lot of things such as:


int systemuptime = GetTickCount();
int secondsuptime;
for (; systemuptime >= 1000; secondsuptime++)
systemuptime -= 1000;
std::cout << secondsuptime; // prints the seconds the system has been online


but i still want to get statistical information of the system such as cpu usage, memory usage, and other miscellaneous things..  any ideas or functions which can do this?
Title: Re:system statistics
Post by: Adron on January 26, 2004, 03:16 PM
Umm, did you ever realize that there's a name for "finding out how many times X (like, X=1000) goes into a number Y"? It's called "division", and the answer is Y / X. :P
Title: Re:system statistics
Post by: dxoigmn on January 26, 2004, 03:20 PM
Quote from: Adron on January 26, 2004, 03:16 PM
Umm, did you ever realize that there's a name for "finding out how many times X (like, X=1000) goes into a number Y"? It's called "division", and the answer is Y / X. :P

To add: secondsuptime isn't even intialized to 0, therefore the value of secondsuptime after that for-loop is arbitrary.
Title: Re:system statistics
Post by: Adron on January 26, 2004, 03:24 PM
That might've been covered by the "such as" part. But I doubt that he'd explain division using a for loop unless that's the way he wrote it. But I suppose that's one way of doing it..
Title: Re:system statistics
Post by: Kp on January 26, 2004, 04:30 PM
You can get CPU usage (broken down by user / kernel / idle time) with GetSystemTimes.  First available in Windows XP SP1 and Windows Server 2003.  To gather information about memory usage, use GlobalMemoryStatus or GlobalMemoryStatusEx.