你可以试试以下的方法取的cpu的id {$R *.DFM} function GetCpuId:longint;assembler;register; var temp:longint; begin asm PUSH EBX PUSH EDI MOV EDI,EAX MOV EAX,1 DW $A20F MOV TEMP,EDX POP EDI POP EBX end; result:=temp; end; procedure TForm1.Button1Click(Sender: TObject); begin Edit1.Text:=IntToHex(GetCpuId,8); end; end. ***************************************************** unit CPUID;interfacetype TCPUID = array[1..4] of Longint; TCPUVendor = array[0..11] of Char;function GetCPUID: TCPUID; assembler; register; function GetCPUVendor: TCPUVendor; assembler; register;implementationfunction 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: TCPUVendor; 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;end. ************************************************* 调用CPUID指令,合并eax,ebx,ecx寄存器的值判断厂商! function TCpuData.GetVendorString:string; var s1,s2,s3:array[0..3] of char; TempVendor:string; i:integer; begin asm push eax push ebx push ecx push edx mov eax,0 db $0F,$A2 /// cpuid mov s1,ebx mov s2,edx mov s3,ecx pop edx pop ecx pop ebx pop eax end; TempVendor:=''; for i:=0 to 3 do TempVendor:=TempVendor+s1[i]; for i:=0 to 3 do TempVendor:=TempVendor+s2[i]; for i:=0 to 3 do TempVendor:=TempVendor+s3[i]; if TempVendor='GenuineIntel' then TempVendor:='Intel' else if TempVendor='AuthenticAMD' then TempVendor:='AMD' else if TempVendor='CyrixInstead' then TempVendor:='Cyrix' else if TempVendor='CentaurHauls' then TempVendor:='IDT' else if TempVendor='NexGenDriven' then TempVendor:='NexGen' else if TempVendor='UMC UMC UMC' then TempVendor:='UMC' else if TempVendor='RiseRiseRise' then TempVendor:='Rise' else if TempVendor='' then TempVendor:='未知'; GetVendorString:=TempVendor; end;然后 调用寄存器eax=1 eax返回 bit 内容 0--3 步进 (stepping) 4--7 型号 (model) 8--11 家族 (family) 通过这三个参数判断具体型号! 如我的雷鸟1.1G三个值为2,4,6! var TempFlags:dword; BinFlags:array[0..31] of byte; i,pos:integer; begin asm push eax push ebx push ecx push edx mov eax,1 mov ebx,0 mov ecx,0 mov edx,0 db $0F,$A2 /// cpuid mov TempFlags,eax pop edx pop ecx pop ebx pop eax end; for i:=0 to 31 do begin BinFlags[i]:=TempFlags mod 2; TempFlags:=TempFlags div 2; end; ptype:=0; family:=0; model:=0; stepping:=0; pos:=0; for i:=0 to 3 do begin stepping:=stepping+(BinFlags[pos]*Trunc(Power(2,i))); inc(pos); end; pos:=4; for i:=0 to 3 do begin model:=model+(BinFlags[pos]*Trunc(Power(2,i))); inc(pos); end; pos:=8; for i:=0 to 3 do begin family:=family+(BinFlags[pos]*Trunc(Power(2,i))); inc(pos); end; pos:=12; for i:=0 to 3 do begin ptype:=ptype+(BinFlags[pos]*Trunc(Power(2,i))); inc(pos); end; end; **************************************************************** 1. Cyrix 厂商识别串: "CyrixInstead" CPU名称 家族 型号 MediaGX 4 4 6x86 5 2 6x86L 5 2 GXm 5 4 6x86MX 6 0
{$R *.DFM} function GetCpuId:longint;assembler;register;
var
temp:longint;
begin
asm
PUSH EBX
PUSH EDI
MOV EDI,EAX
MOV EAX,1
DW $A20F
MOV TEMP,EDX
POP EDI
POP EBX
end;
result:=temp;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Edit1.Text:=IntToHex(GetCpuId,8);
end;
end.
*****************************************************
unit CPUID;interfacetype
TCPUID = array[1..4] of Longint;
TCPUVendor = array[0..11] of Char;function GetCPUID: TCPUID; assembler; register;
function GetCPUVendor: TCPUVendor; assembler; register;implementationfunction 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: TCPUVendor; 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;end.
*************************************************
调用CPUID指令,合并eax,ebx,ecx寄存器的值判断厂商! function TCpuData.GetVendorString:string;
var s1,s2,s3:array[0..3] of char;
TempVendor:string;
i:integer;
begin
asm
push eax
push ebx
push ecx
push edx
mov eax,0
db $0F,$A2 /// cpuid
mov s1,ebx
mov s2,edx
mov s3,ecx
pop edx
pop ecx
pop ebx
pop eax
end;
TempVendor:='';
for i:=0 to 3 do
TempVendor:=TempVendor+s1[i];
for i:=0 to 3 do
TempVendor:=TempVendor+s2[i];
for i:=0 to 3 do
TempVendor:=TempVendor+s3[i];
if TempVendor='GenuineIntel' then
TempVendor:='Intel'
else if TempVendor='AuthenticAMD' then
TempVendor:='AMD'
else if TempVendor='CyrixInstead' then
TempVendor:='Cyrix'
else if TempVendor='CentaurHauls' then
TempVendor:='IDT'
else if TempVendor='NexGenDriven' then
TempVendor:='NexGen'
else if TempVendor='UMC UMC UMC' then
TempVendor:='UMC'
else if TempVendor='RiseRiseRise' then
TempVendor:='Rise'
else if TempVendor='' then
TempVendor:='未知';
GetVendorString:=TempVendor;
end;然后
调用寄存器eax=1
eax返回
bit 内容
0--3 步进 (stepping)
4--7 型号 (model)
8--11 家族 (family)
通过这三个参数判断具体型号!
如我的雷鸟1.1G三个值为2,4,6! var TempFlags:dword;
BinFlags:array[0..31] of byte;
i,pos:integer;
begin
asm
push eax
push ebx
push ecx
push edx
mov eax,1
mov ebx,0
mov ecx,0
mov edx,0
db $0F,$A2 /// cpuid
mov TempFlags,eax
pop edx
pop ecx
pop ebx
pop eax
end;
for i:=0 to 31 do
begin
BinFlags[i]:=TempFlags mod 2;
TempFlags:=TempFlags div 2;
end;
ptype:=0;
family:=0;
model:=0;
stepping:=0;
pos:=0;
for i:=0 to 3 do
begin
stepping:=stepping+(BinFlags[pos]*Trunc(Power(2,i)));
inc(pos);
end;
pos:=4;
for i:=0 to 3 do
begin
model:=model+(BinFlags[pos]*Trunc(Power(2,i)));
inc(pos);
end;
pos:=8;
for i:=0 to 3 do
begin
family:=family+(BinFlags[pos]*Trunc(Power(2,i)));
inc(pos);
end;
pos:=12;
for i:=0 to 3 do
begin
ptype:=ptype+(BinFlags[pos]*Trunc(Power(2,i)));
inc(pos);
end;
end;
****************************************************************
1. Cyrix
厂商识别串: "CyrixInstead"
CPU名称 家族 型号
MediaGX 4 4
6x86 5 2
6x86L 5 2
GXm 5 4
6x86MX 6 0
2. NexGen
厂商识别串: "NexGenDriven"
CPU名称 家族 型号
Nx586 5 3. UMC
厂商识别串: "UMC UMC UMC "
CPU名称 家族 型号
U5D 4 1
U5S 4 24. AMD
厂商识别串: "AuthenticAMD"
CPU名称 家族 型号
486DX2WT 4 3
486DX2WB 4 7
486DX4WT 4 8
486DX4WB 4 9
5x86WT 4 0x0e
5x86WB 4 0x0f
486 4 Others
K5/SS 5 0
K5 5 1,2,3
K6 5 6,7
K6-2 5 8
K6-III 5 9
K5/K6 5 Others
K7工程样本 6 0
K7 6 Others5. IDT
厂商识别串: "CentaurHauls"
CPU名称 家族 型号
WinChip C6 5 4
WinChip 2 5 86 Rise
厂商识别串: "RiseRiseRise"
CPU名称 家族 型号
mP6 5 07. Intel
厂商识别串: "GenuineIntel"
CPU名称 家族 型号
PentiumII 6 3
Celeron 6 5
CeleronA 6 6
PentiumIII 6 7
PentiumPro OverDrive P6 6 1
PentiumPro 6 Others
PentiumP5 5 1
PentiumP54C 5 2
Pentiumi486 5 3
PentiumMMX 5 4
PentiumDX4 5 5
Pentium OverDrive P5 5 6
Pentium 5 Others
486DX 4 0,1
486SX 4 2
486DX2 4 3
486SL 4 4
486SX2 4 5
486DX2_WB 4 7
486DX4 4 8
8.Intel
厂商识别串: "GenuineIntel" Celeron 7,8 1
Pentium III Xeon 7,8 3
Pentium IV 7,8 4
Pentium III 7,8 L2Cache<1024
Pentium III Xeon 7,8 other
Pentium III Xeon 10($A)
Pentium VI or Ithanium 15($F)