uses ActiveX, ComObj;
//这个函数使用了WMI,而且只获取第一个硬件/软件设置的信息。
//用户可以根据需要自行修改。
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;
if VarIsArray(Obj) then Result:=Obj[0]
else Result:=Obj;
end;
函数的调用:
procedure TForm1.btn6Click(Sender: TObject);
begin
ShowMessage(GetWMIProperty('BIOS','BIOSVersion')); //获得BIOS版本
ShowMessage(GetWMIProperty('DiskDrive','PNPDeviceID')); //获得第一块硬盘的设备标示
ShowMessage(GetWMIProperty('Processor','ProcessorId')); //获得CPUID。
end;
文档说明:
相关文档
返回首页 | 关于本站 | | 友情链接 | 广告服务 | 意见建议 | 访客留言 | 本站论坛
Copyright© 2001-2006 ProgramBBS.com All Rights Reserved 版权所有©编程论坛
Email: 吉ICP备05009985号
感谢长春订餐网友情支持