如何讀取CPU的序號問題 |
尚未結案
|
willis
一般會員 發表:9 回覆:11 積分:4 註冊:2002-09-12 發送簡訊給我 |
我在本站找到一範例程式中找到一段code能將cpu序號讀出,不過是用Delphi撰寫,小弟我因看不懂delphi語法,所以不知如何轉成BCB,各位新進幫個忙吧,程式碼如下: unit Unit1; interface uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,shellapi; type
TForm1 = class(TForm)
Button1: TButton;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end; var
Form1: TForm1; implementation {$R *.dfm}
type
TCPUID = array[1..4] of Longint;
TVendor = array [0..11] of char; function GetCPUID : TCPUID; assembler; register;
asm
PUSH EBX {Save affected register}
PUSH EDI
MOV EDI,EAX {@Resukt}
MOV EAX,1
DW $A20F {CPUID Command}
STOSD {CPUID[1]}
MOV EAX,EBX
STOSD {CPUID[2]}
MOV EAX,ECX
STOSD {CPUID[3]}
MOV EAX,EDX
STOSD {CPUID[4]}
POP EDI {Restore registers}
POP EBX
end; function GetCPUVendor : TVendor; assembler; register;
asm
PUSH EBX {Save affected register}
PUSH EDI
MOV EDI,EAX {@Result (TVendor)}
MOV EAX,0
DW $A20F {CPUID Command}
MOV EAX,EBX
XCHG EBX,ECX {save ECX result}
MOV ECX,4
@1:
STOSB
SHR EAX,8
LOOP @1
MOV EAX,EDX
MOV ECX,4
@2:
STOSB
SHR EAX,8
LOOP @2
MOV EAX,EBX
MOV ECX,4
@3:
STOSB
SHR EAX,8
LOOP @3
POP EDI {Restore registers}
POP EBX
end; procedure TForm1.Button1Click(Sender: TObject);
var
CPUID : TCPUID;
I : Integer;
S : TVendor;
begin
for I := Low(CPUID) to High(CPUID) do CPUID[I] := -1;
CPUID := GetCPUID;
Label1.Caption := 'CPUID[1] = ' IntToHex(CPUID[1],8);
Label2.Caption := 'CPUID[2] = ' IntToHex(CPUID[2],8);
Label3.Caption := 'CPUID[3] = ' IntToHex(CPUID[3],8);
Label4.Caption := 'CPUID[4] = ' IntToHex(CPUID[4],8);
S := GetCPUVendor;
Label5.Caption := S;
end; end. 各位大大幫幫忙,謝謝
|
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |