function TForm1.GetCpuInfo:string;
var R: array[0..19] of Char;
var CpuID: Integer;
begin
FillChar(R, 20, 0);
asm
mov eax, 0
db 0fh, 0a2h // 其实就是cpuid汇编指令
mov dword ptr R[0], ebx
mov dword ptr R[4], edx
mov dword ptr R[8], ecx
mov eax, 1
db 0fh, 0a2h // cpuid
mov CpuID, edx
end;
ShowMessage('CPU制造商为:' + R);
ShowMessage('序列号为:' + IntToStr(CpuID));
result:=inttostr(cpuid);
end;procedure TForm1.Button1Click(Sender: TObject);
var s:string;
begin
s:=getcpuinfo;
form1.caption:=s;
edit1.Text:=s;
memo1.Lines.Add(getcpuinfo);end;
var R: array[0..19] of Char;
var CpuID: Integer;
begin
FillChar(R, 20, 0);
asm
mov eax, 0
db 0fh, 0a2h // 其实就是cpuid汇编指令
mov dword ptr R[0], ebx
mov dword ptr R[4], edx
mov dword ptr R[8], ecx
mov eax, 1
db 0fh, 0a2h // cpuid
mov CpuID, edx
end;
ShowMessage('CPU制造商为:' + R);
ShowMessage('序列号为:' + IntToStr(CpuID));
result:=inttostr(cpuid);
end;procedure TForm1.Button1Click(Sender: TObject);
var s:string;
begin
s:=getcpuinfo;
form1.caption:=s;
edit1.Text:=s;
memo1.Lines.Add(getcpuinfo);end;
改成这样:function GetCpuInfo:string;
var R: array[0..19] of Char;
var CpuID: Integer;
begin
FillChar(R, 20, 0);
asm
push eax
push ebx
push ecx
push edx
mov eax, 0
db 0fh, 0a2h // 其实就是cpuid汇编指令
mov dword ptr R[0], ebx
mov dword ptr R[4], edx
mov dword ptr R[8], ecx
mov eax, 1
db 0fh, 0a2h // cpuid
mov CpuID, edx
pop edx
pop ecx
pop ebx
pop eax
end;
ShowMessage('CPU制造商为:' + R);
ShowMessage('序列号为:' + IntToStr(CpuID));
result:=inttostr(cpuid);
end;
Result:=CpuId;改这两处吧