?
Solved

How do I get CPU Clock Speed

Posted on 1997-05-16
5
Medium Priority
?
374 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 100 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
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: …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

765 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