Solved

How do I get CPU Clock Speed

Posted on 1997-05-16
5
352 Views
Last Modified: 2010-04-04
How do I get CPU Clock Speed (200 MHz, 166 MHz, etc.) within
my Delphi 2.0 program.  I have tried about 10 different "System Info" components and none return this information.
I cannot find it in the registry either.  I really need a way to get this on all Windows platforms, but definitely in Win95 and WinNT.  I'm brand new to Delphi, so this is probably easy for some of you.  Please help a new guy.  Thanks in advance for your time.
0
Comment
Question by:Rik
  • 3
  • 2
5 Comments
 
LVL 3

Accepted Solution

by:
sperling earned 50 total points
ID: 1336359
Didn't I answer this on news???

Anyway, this works for Win95 and NT if the hardware supports it.


function CPUFrequency : SINGLE;
var
  li     : TLargeInteger;
begin
  QueryPerformanceFrequency(li);
  Result := li.QuadPart / 10000;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  Label1.Caption := FloatToStrF(CPUFrequency, ffFixed, 6, 2);
end;


Don't know how you can get this for Win 3.1 though.

Regards,

Erik.
0
 

Author Comment

by:Rik
ID: 1336360
Didn't see your response on News Group.  Thank you, it worked!!
What is 'Quadpart', can't find any documentation on that?
0
 

Author Comment

by:Rik
ID: 1336361
Erik,

I'm not quite sure that solution worked.  It seemed to as it returned 119.20 when I was at work on a 120 MHz, but I am now at home and I am on a 200 MHz and it is returning 119.32.  Any ideas?  
0
 
LVL 3

Expert Comment

by:sperling
ID: 1336362
Funny.

According to the docs, the return value is the *true* CPU speed (Doesn't always match the vendors specs). It is calculated by reading the same counter that is used to generate the CPU frequency. It works on my computers, I'm sorry I can't help about the 200MHz (Is the 200MHz a Intel CPU, BTW?)

The quadpart is a 'Comp', which is borlands 64-bit signed integer value. It can't be used for much besides storing values and converting to floats, as you can't normally use DIV MOD and so on on a comp.


Regards,

Erik.
0
 

Author Comment

by:Rik
ID: 1336363
Erik,

Tried the code on a 75 MHz today and it too displayed 119.32 MHz.
Yes, the 200 MHz is an Intel.  When I boot up, the first thing displayed is 'Pentium = 200 MHz'.  If you hear of another way to get the clock speed, please let me know.  Thank you for your time.
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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

911 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

17 Experts available now in Live!

Get 1:1 Help Now