首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

delphi读cpu序列号有关问题

2012-03-05 
delphi读cpu序列号问题下面代码大家帮测试下。是不是都能获得值。有错误弹出没??Delphi(Pascal) codefunctio

delphi读cpu序列号问题
下面代码大家帮测试下。是不是都能获得值。有错误弹出没??

Delphi(Pascal) code
function GetCpuInfo(): string;var  R: array[0..19] of Char;  CID: Integer;begin  FillChar(R, 20, 0);  asm    push ebx    push ecx    push edx    mov eax, 0    cpuid    mov dword ptr R[0], ebx    mov dword ptr R[4], edx    mov dword ptr R[8], ecx    mov eax, 1    cpuid    mov CID, edx    pop edx    pop ecx    pop ebx  end;  Result := R + inttostr(CID);end;


[解决办法]
运行showmessage(GetCpuInfo);能获得cpu号,没错误提示。
[解决办法]
没错误,但乱码(win7 64 + delphi 2010)

[解决办法]
另一方法,用WMI,你可得到你所有想要的,且兼容所有windows系统
Delphi(Pascal) code
implementation uses ActiveX, ComObj;{$R *.dfm}function GetWMIProperty(WMIType, WMIProperty:String):String;var  Wmi, Objs, Obj:OleVariant;  Enum:IEnumVariant;  C:Cardinal;begin  try    Wmi:= CreateOleObject('WbemScripting.SWbemLocator');    Objs := Wmi.ConnectServer('.','root\cimv2').ExecQuery('Select * from Win32_'+ WMIType);    Enum:=IEnumVariant(IUnknown(Objs._NewEnum));    Enum.Reset;    Enum.Next(1,Obj,C);        Obj:=Obj.Properties_.Item(WMIProperty,0).Value;    if VarIsArray(Obj) then Result:=Obj[0]    else Result:=Obj;    except     Result:='error';  end;end;procedure TForm1.Button1Click(Sender: TObject);begin  ShowMessage(GetWMIProperty('BIOS','BIOSVersion'));          //获得BIOS版本  ShowMessage(GetWMIProperty('DiskDrive','SerialNumber'));     //获得第一块硬盘的设备标示  ShowMessage(GetWMIProperty('Processor','ProcessorId'));     //获得CPUID。end;
[解决办法]
没有报错,厂商是对的,不过ID不知道对不对。
[解决办法]
delphi7 + win2003

GetCpuInfo没有出错误,不知道结果对不对

出错误
ShowMessage(GetWMIProperty('DiskDrive','SerialNumber')); //获得第一块硬盘的设备标示

热点排行