Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How do I get CPU Clock Speed

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

604 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