Solved

processor info

Posted on 2001-09-15
5
203 Views
Last Modified: 2010-04-06
how can i get the processor name and speed?

i would like them put into separate labels.

eg label1 = name
   label2 = speed


thanks


kevin ward
0
Comment
Question by:kevinward66
5 Comments
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 6485413
Hello

  you can download free component with source from
http://www.torry.net/cpu.htm
0
 

Author Comment

by:kevinward66
ID: 6486021
if possible i would rather CODE than components!!!
0
 
LVL 1

Expert Comment

by:Dennis9
ID: 6486104
This code should do it:

function GetCPUSpeed: Double;
const
  DelayTime = 500; // measure time in ms
var
  TimerHi, TimerLo: DWORD;
  PriorityClass, Priority: Integer;
begin
  PriorityClass := GetPriorityClass(GetCurrentProcess);
  Priority := GetThreadPriority(GetCurrentThread);

  SetPriorityClass(GetCurrentProcess, REALTIME_PRIORITY_CLASS);
  SetThreadPriority(GetCurrentThread, THREAD_PRIORITY_TIME_CRITICAL);

  Sleep(10);
  asm
    dw 310Fh // rdtsc
    mov TimerLo, eax
    mov TimerHi, edx
  end;
  Sleep(DelayTime);
  asm
    dw 310Fh // rdtsc
    sub eax, TimerLo
    sbb edx, TimerHi
    mov TimerLo, eax
    mov TimerHi, edx
  end;

  SetThreadPriority(GetCurrentThread, Priority);
  SetPriorityClass(GetCurrentProcess, PriorityClass);

  Result := TimerLo / (1000.0 * DelayTime);
end;

//Then just call it like
Label1.Caption := Format('%f MHz', [GetCPUSpeed]);



I can't remember if there is any special in the uses cluse, but if u have problems i will try to find what u need.

Dennis
0
 
LVL 22

Accepted Solution

by:
Mohammed Nasman earned 100 total points
ID: 6486197
Hello

  Here's a sample to get the cpu speed and name, I got the cpu name from the registry, and it's worked fine with my processor (AMD Athlon 900MHz)

Just add two labels, and one button, here's the complete code

//===========

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Label1: TLabel;
    Label2: TLabel;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}
uses Registry;

function GetCpuSpeed: string;
var
  t: DWORD;
  mhi, mlo, nhi, nlo: DWORD;
  t0, t1, chi, clo, shr32: Comp;
begin
  shr32 := 65536;
  shr32 := shr32 * 65536;
  t := GetTickCount;
  while t = GetTickCount do begin end;
  asm
    DB 0FH
    DB 031H
    mov mhi,edx
    mov mlo,eax
  end;

  while GetTickCount < (t + 1000) do begin end;
  asm
    DB 0FH
    DB 031H
    mov nhi,edx
    mov nlo,eax
  end;
  chi := mhi; if mhi < 0 then chi := chi + shr32;
  clo := mlo; if mlo < 0 then clo := clo + shr32;
  t0 := chi * shr32 + clo;
  chi := nhi; if nhi < 0 then chi := chi + shr32;
  clo := nlo; if nlo < 0 then clo := clo + shr32;
  t1 := chi * shr32 + clo;
  Result := FloatToStr((t1 - t0) / 1E6);
end;

function  GetCpuName : string;
var
  Registry: TRegistry;
  S:  string ;
begin
  Registry:=TRegistry.Create;
  Registry.RootKey:=HKEY_LOCAL_MACHINE;
  Registry.OpenKey('\Hardware\Description\System\CentralProcessor\0',False);
  Result :=Registry.ReadString('Identifier');
  Registry.Free;
end ;

procedure TForm1.Button1Click(Sender: TObject);
begin
  Label1.Caption := GetCpuSpeed;
  Label2.Caption := GetCpuName;
end;
end.

Best regards
Mohammed Nasman
0
 
LVL 3

Expert Comment

by:VSF
ID: 6487288
At Simonets place u will find a sample called CPUID that returns to you processor speed and name, with source!
http://www.bhnet.com.br/~simonet/index.html

If u have any problems downloading or findig it, e-mail me and I'll send the complete sample to you!

Hope this helps!
VSF
www.victory.hpg.com.br
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

Suggested Solutions

Title # Comments Views Activity
Using idhttp to login to instagram 2 76
Printing problem 2 80
Strange behavior when a form is closed 6 51
How to convert memory stream to PDF file 6 18
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
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 …
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

896 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

14 Experts available now in Live!

Get 1:1 Help Now