Solved

processor info

Posted on 2001-09-15
5
207 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
[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
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
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…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

733 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