Solved

How do I get CPU Clock Speed

Posted on 1997-05-16
5
366 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

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…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

688 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