Hardware Delphi

Unit Unit2;
Interface
Uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
Type
TForm1=Class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel; // CPU Vendor'un yazılacağı etiket
Label8: TLabel; // CPU Type'ın yazılacağı etiket
Label9: TLabel; // CPU Family'nin yazılacağı etiket
Label10: TLabel; // CPU Model'in yazılacağı etiket
Label11: TLabel; // CPU Stepping'in yazılacağı etiket
Label12: TLabel; // CPU Signature'un yazılacağı etiket
Function HasCpuId: Boolean;
Function CpuSignature:Longword;
Function CpuType(Const Signature:Longword):Byte;
Function CpuFamily(Const Signature:Longword):Byte;
Function CpuModel(Const Signature:Longword):Byte;
Function CpuStepping(Const Signature:Longword):Byte;
Function CpuVendor:String;
Procedure FormCreate(Sender:TObject);
private
Public
End;
Var
Form1: TForm1;
Implementation
{$R *.dfm}
Function TForm1.CpuVendor:String;
Const
SID : Array[0..11] Of Char='';
Begin
Asm
CALL HasCpuId
CMP AL, TRUE
JNE @Tamam
PUSH EBX
XOR EAX, EAX
DW $A20F
MOV DWORD PTR SID, EBX
MOV DWORD PTR SID[4], EDX
MOV DWORD PTR SID[8], ECX
POP EBX
@Tamam:
End;
Result:=SID;
End;
Function TForm1.CpuType(Const Signature: Longword):Byte;
Asm
SHR EAX, 12
AND EAX, $03
End;
Function TForm1.CpuFamily(Const Signature: Longword):Byte;
Asm
SHR EAX, 8
AND EAX, $F
End;
Function TForm1.CpuModel(Const Signature: Longword):Byte;
Asm
SHR EAX, 4
AND EAX, $F
End;
Function TForm1.CpuStepping(Const Signature: Longword):Byte;
Asm
AND EAX, $F
End;
Function TForm1.CpuSignature:Longword;
Asm
CALL HasCpuId
CMP AL, TRUE
JNE @Bilinmeyen
PUSH EBX
XOR EAX, EAX
DW $A20F
POP EBX
CMP EAX, 1
JL @Bilinmeyen
JMP @CpuId1
@Bilinmeyen:
XOR EAX, EAX
JMP @Son
@CpuId1:
PUSH EBX
MOV EAX, 1
DW $A20F
POP EBX
@Son:
End;
Function TForm1.HasCpuId:Boolean;
Asm
MOV EDX, FALSE
PUSHFD
POP EAX
MOV ECX, EAX
XOR EAX, $200000
PUSH EAX
POPFD
PUSHFD
POP EAX
XOR ECX, EAX
JZ @Atla
MOV EDX, TRUE
@Atla:
PUSH EAX
POPFD
MOV EAX, EDX
End;
Procedure TForm1.FormCreate(Sender: TObject);
Begin
Label7.Caption:=CPUVendor;
Label8.Caption:=IntToStr(CPUType(CPUSignature));
Label9.Caption:=IntToStr(CPUFamily(CPUSignature));
Label10.Caption:=IntToStr(CPUModel(CPUSignature));
Label11.Caption:=IntToStr(CPUStepping(CPUSignature));
Label12.Caption:=IntToStr(CPUSignature);
End;
End.
// Kolay gelsin.
//
// Hakan HAMURCU
//
// hakan@hamurcu.com