?
Solved

processor info

Posted on 2001-09-15
5
Medium Priority
?
209 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 400 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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…
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…
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…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses
Course of the Month14 days, 21 hours left to enroll

770 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