mersenneforum.org  

Go Back   mersenneforum.org > Extra Stuff > Programming

Reply
 
Thread Tools
Old 2003-10-17, 00:21   #1
PrimeCruncher
 
PrimeCruncher's Avatar
 
Sep 2003
Borg HQ, Delta Quadrant

10101111102 Posts
Default Tray icon OS/CPU/Uptime prog

This program uses a generic icon which, when the mouse hovers over it, displays the OS, the speed and manufacturer of the CPU, and the uptime of the system.
Attached Files
File Type: zip dp3.zip (2.0 KB, 327 views)
PrimeCruncher is offline   Reply With Quote
Old 2003-10-17, 11:38   #2
xilman
Bamboozled!
 
xilman's Avatar
 
"π’‰Ίπ’ŒŒπ’‡·π’†·π’€­"
May 2003
Down not across

101011000011112 Posts
Default Re: Tray icon OS/CPU/Uptime prog

Quote:
Originally posted by PrimeCruncher
This program uses a generic icon which, when the mouse hovers over it, displays the OS, the speed and manufacturer of the CPU, and the uptime of the system.
Not sure it works properly. I also think I know what you need to do to fix it. On my system I get

XP Intel -1762: 1 days, 2 hours, 37 minutes


Some of this is correct. It is an Intel P4 running XP Pro. According to another uptime program:

% /Z/uptime.exe
\\MSRC-RAT has been up for: 1 day(s), 2 hour(s), 38 minute(s), 6 second(s)
%

Note that your program doesn't properly handle singular and plural units of time. You should test for 1 of each unit and drop the 's' in those cases. This might sound fussy, but it does show whether you care enough to do a job properly rather than cutting corners for simplicity.

The real problem, though, is the displayed clock speed. My machine is actually a 2.53GHz machine. Converting the displayed MHz to GHz, we get -1.762 GHz, which is clearly wrong.

I observe that 2^32 - 2.53*10^9 is 1.765*10^9. It seems virtually certain that your code internally stores Hz, and not MHz, and does so in a signed 32-bit number. Any frequency over 2^31 Hz (about 2GHz) is going to overflow the variable.

There are several workarounds, some better than others. A poor one is to use a 32-bit unsigned variable. This will break when clock frequencies increase beyond 4.29GHz, which is likely to happen within a year or so. A much better one is to use a larger variable, 64 bits probably, which will be adequate for a long time to come. Another possibility, intermediate in desirability in my view, is to obtain the clock frequency in larger units, perhaps MHz, so that a 32-bit variable has an adequate range.

Paul
xilman is offline   Reply With Quote
Old 2003-10-17, 14:06   #3
PrimeCruncher
 
PrimeCruncher's Avatar
 
Sep 2003
Borg HQ, Delta Quadrant

2×33×13 Posts
Default

WHAT?? BUGS?? IN MY SOFTWARE??

Thanks for the heads-up, will check this out. At the time I wrote this I had no 2+ GHz PCs here but I will see if the current version is affected on my C 2GHz so I have a testbed.

I would adjust the plural/singular grammar but the program uses a format string (wsprintf), so I would have to:

a) create a format control string for each possibility, check, then format the correct one

or

b) create two strings for each number (day/hr/min) and do either repetitive lstrcats or use a generic format string

Either way will require a ton of programming that, at this time, I'm not willing to do. My motto is: if it's not broken, don't fix it.
PrimeCruncher is offline   Reply With Quote
Old 2003-10-17, 18:14   #4
Wacky
 
Wacky's Avatar
 
Jun 2003
The Texas Hill Country

21018 Posts
Default

Quote:
Originally posted by PrimeCruncher
My motto is: if it's not broken, don't fix it.
But it is broken .....
Wacky is offline   Reply With Quote
Old 2003-10-17, 19:10   #5
PrimeCruncher
 
PrimeCruncher's Avatar
 
Sep 2003
Borg HQ, Delta Quadrant

2BE16 Posts
Default

And I intend to fix the part that is broken.
PrimeCruncher is offline   Reply With Quote
Reply

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to hide icon in system tray? ccstpaul Software 2 2006-04-12 03:50
LLRnet starts as a system tray icon vaughan Prime Sierpinski Project 1 2005-01-26 15:43
Tray Icon won't vanish in XP saherr1969 Software 2 2003-06-15 20:39
Problem with the Tray Icon under Win 98 Reboot It Software 6 2002-09-06 23:52
IDEA: Additional options in tray icon menu gowen72 Software 8 2002-09-04 17:24

All times are UTC. The time now is 15:33.


Sun Nov 28 15:33:17 UTC 2021 up 128 days, 10:02, 0 users, load averages: 1.13, 1.07, 1.14

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.

This forum has received and complied with 0 (zero) government requests for information.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.
A copy of the license is included in the FAQ.