delphi 获得cpu硬件信息 delphi 获得cpu硬件信息 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://www.google.cn/search?hl=zh-CN&client=firefox-a&rls=org.mozilla%3Azh-CN%3Aofficial&hs=sfi&newwindow=1&q=delphi+cpu%E7%A1%AC%E4%BB%B6%E4%BF%A1%E6%81%AF&btnG=Google+%E6%90%9C%E7%B4%A2&aq=f&oq= http://hi.baidu.com/t810509/blog/item/0d8d3d986a66b70f6f068c7f.html //GetIp function LocalIP : string; type TaPInAddr = array [0..10] of PInAddr; PaPInAddr = ^TaPInAddr; var phe : PHostEnt; pptr : PaPInAddr; Buffer : array [0..63] of char; I : Integer; GInitData : TWSADATA; begin WSAStartup($101, GInitData); Result := ``; GetHostName(Buffer, SizeOf(Buffer)); phe :=GetHostByName(buffer); if phe = nil then Exit; pptr := PaPInAddr(Phe^.h_addr_list); I := 0; while pptr^[I] <> nil do begin result:=StrPas(inet_ntoa(pptr^[I]^)); Inc(I); end; WSACleanup; end; function TCpuInfo.GetCPUID: string; begin {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;} Result := IntToHex(FEAXValue, 8) + '- ' + IntToHex(FEBXValue, 8) + '- ' + IntToHex(FECXValue, 8) + '- ' + IntToHex(FEDXValue, 8) end; function GetCpuId:longint; 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; WMI也可獲取系統硬件信息uses ActiveX, ComObj;function GetWMIProperty(WMIType, WMIProperty: string): string;var Wmi, Objs, Obj: OleVariant; Enum: IEnumVariant; C: Cardinal;begin 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; Result := Obj;end; // 獲取硬碟序號ShowMessage(GetWMIProperty('DiskDrive', 'PNPDeviceID'));// 獲取BISO序號ShowMessage(GetWMIProperty('BIOS', 'SerialNumber'));// 獲取網卡MAC位址ShowMessage(GetWMIProperty('NetworkAdapter', 'MACAddress'));// 獲取網卡序號ShowMessage(GetWMIProperty('NetworkAdapter', 'PNPDeviceID'));// 獲取CPU序號ShowMessage(GetWMIProperty('Processor', 'ProcessorId'));也可以用同樣的方法獲得任意感興趣的系統資訊,比如正在運行的進程、帳戶資訊等等。function GetComputerType(TypeValue: integer): string;begin case TypeValue of 1: Result := 'Other'; 2: Result := 'Unknown'; 3: Result := 'Desktop'; 4: Result := 'LowProfileDesktop'; 5: Result := 'PizzaBox'; 6: Result := 'MiniTower'; 7: Result := 'Tower'; 8: Result := 'Portable'; 9: Result := 'Laptop'; 10: Result := 'Notebook'; 11: Result := 'Handheld'; 12: Result := 'DockingStation'; 13: Result := 'AllInOne'; 14: Result := 'SubNotebook'; 15: Result := 'SpaceSaving'; 16: Result := 'LunchBox'; 17: Result := 'MainSystemChassis'; 18: Result := 'ExpansionChassis'; 19: Result := 'SubChassis'; 20: Result := 'BusExpansionChassis'; 21: Result := 'PeripheralChassis'; 22: Result := 'StorageChassis'; 23: Result := 'RackMountChassis'; 24: Result := 'SealedCasePC'; end;end;procedure TForm4.Button1Click(Sender: TObject);var s: string;begin s := GetComputerType(StrToInt(getwmiproperty('SystemEnclosure', 'ChassisTypes'))); showmessage(s);end; 还是一个多人提到的问题 一个delphi的语句怎样改成 vc 高分,求解.http代理问题 TPageControl控件问题!!! 用ADOQuery查询时怎样把数字类型转化为文本类型? 为什么我的中间层要多次被执行? 请问如何判断一表是否被修改过?(我用TTable) 怎么样去掉句柄 请教各位大虾一个问题。 请介绍几本学DELPHI好书! 键盘hook问题 Delphi2011支持Win64编译吗?
function LocalIP : string;
type
TaPInAddr = array [0..10] of PInAddr;
PaPInAddr = ^TaPInAddr;
var
phe : PHostEnt;
pptr : PaPInAddr;
Buffer : array [0..63] of char;
I : Integer;
GInitData : TWSADATA;
begin
WSAStartup($101, GInitData);
Result := ``;
GetHostName(Buffer, SizeOf(Buffer));
phe :=GetHostByName(buffer);
if phe = nil then Exit;
pptr := PaPInAddr(Phe^.h_addr_list);
I := 0;
while pptr^[I] <> nil do begin
result:=StrPas(inet_ntoa(pptr^[I]^));
Inc(I);
end;
WSACleanup;
end; function TCpuInfo.GetCPUID: string;
begin
{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;}
Result := IntToHex(FEAXValue, 8) + '- ' + IntToHex(FEBXValue, 8) + '- ' + IntToHex(FECXValue, 8) + '- ' + IntToHex(FEDXValue, 8)
end; function GetCpuId:longint;
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;
var
Wmi, Objs, Obj: OleVariant;
Enum: IEnumVariant;
C: Cardinal;
begin
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;
Result := Obj;
end;
// 獲取硬碟序號
ShowMessage(GetWMIProperty('DiskDrive', 'PNPDeviceID'));
// 獲取BISO序號
ShowMessage(GetWMIProperty('BIOS', 'SerialNumber'));
// 獲取網卡MAC位址
ShowMessage(GetWMIProperty('NetworkAdapter', 'MACAddress'));
// 獲取網卡序號
ShowMessage(GetWMIProperty('NetworkAdapter', 'PNPDeviceID'));
// 獲取CPU序號
ShowMessage(GetWMIProperty('Processor', 'ProcessorId'));也可以用同樣的方法獲得任意感興趣的系統資訊,比如正在運行的進程、帳戶資訊等等。function GetComputerType(TypeValue: integer): string;
begin
case TypeValue of
1: Result := 'Other';
2: Result := 'Unknown';
3: Result := 'Desktop';
4: Result := 'LowProfileDesktop';
5: Result := 'PizzaBox';
6: Result := 'MiniTower';
7: Result := 'Tower';
8: Result := 'Portable';
9: Result := 'Laptop';
10: Result := 'Notebook';
11: Result := 'Handheld';
12: Result := 'DockingStation';
13: Result := 'AllInOne';
14: Result := 'SubNotebook';
15: Result := 'SpaceSaving';
16: Result := 'LunchBox';
17: Result := 'MainSystemChassis';
18: Result := 'ExpansionChassis';
19: Result := 'SubChassis';
20: Result := 'BusExpansionChassis';
21: Result := 'PeripheralChassis';
22: Result := 'StorageChassis';
23: Result := 'RackMountChassis';
24: Result := 'SealedCasePC';
end;
end;
procedure TForm4.Button1Click(Sender: TObject);
var
s: string;
begin
s := GetComputerType(StrToInt(getwmiproperty('SystemEnclosure', 'ChassisTypes')));
showmessage(s);
end;