风吹小机机 Posted September 24, 2022 Share Posted September 24, 2022 The main purpose of obtaining equipment information is to verify the validity of the software What good way do you have? No, Under the application program, this code can obtain the device information But an error is reported in UNGUI uses NB30, Winapi.ActiveX, System.Win.ComObj; {$region 'function GetWMIProperty(WMIType, WMIProperty: AnsiString): string;'} function GetWMIProperty(WMIType, WMIProperty: AnsiString): string; var Wmi, Objs, Obj: OleVariant; Enum: IEnumVariant; 😄 Cardinal; begin try Wmi := CreateOleObject(AnsiString('WbemScripting.SWbemLocator')); Objs := Wmi.ConnectServer(AnsiString('.'), AnsiString('root\cimv2')).ExecQuery(AnsiString('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; {$ENDREGION} //获取计算机名称 function GetComputerName: string; begin Exit(GetWMIProperty('OperatingSystem', 'CSName')); end; //获取BISO序列号 function GetBIOSSerialNumber: string; begin Exit(GetWMIProperty('BIOS', 'SerialNumber')); end; procedure TForm1.Button1Click(Sender: TObject); begin Memo1.Lines.Clear; Memo1.Lines.Add(GetComputerName); Memo1.Lines.Add(GetBIOSSerialNumber); end; Quote Link to comment Share on other sites More sharing options...
Sherzod Posted September 24, 2022 Share Posted September 24, 2022 Hello, What do you want in general? What device, server machine, client machine!? Quote Link to comment Share on other sites More sharing options...
风吹小机机 Posted September 24, 2022 Author Share Posted September 24, 2022 server machine Quote Link to comment Share on other sites More sharing options...
风吹小机机 Posted September 24, 2022 Author Share Posted September 24, 2022 Just now, Sherzod said: Hello, What do you want in general? What device, server machine, client machine!? server machine Quote Link to comment Share on other sites More sharing options...
Sherzod Posted September 24, 2022 Share Posted September 24, 2022 53 minutes ago, 风吹小机机 said: But an error is reported in UNGUI Which error? Quote Link to comment Share on other sites More sharing options...
风吹小机机 Posted September 24, 2022 Author Share Posted September 24, 2022 Just now, Sherzod said: Which error? Access violation at address 75948970 in module 'combase.dll'. Read of address 00000000 Quote Link to comment Share on other sites More sharing options...
Abaksoft Posted September 24, 2022 Share Posted September 24, 2022 53 minutes ago, 风吹小机机 said: server machine We are using WMI Technic. Thx to : Rodrigo Ruz https://github.com/RRUZ/wmi-delphi-code-creator See our mini Unigui project in attachment : WMI_Unigui.7z Quote Link to comment Share on other sites More sharing options...
风吹小机机 Posted September 24, 2022 Author Share Posted September 24, 2022 Just now, Abaksoft said: We are using WMI Technic. Thx to : Rodrigo Ruz https://github.com/RRUZ/wmi-delphi-code-creator See our mini Unigui project in attachment : WMI_Unigui.7z 86.9 kB · 1 download Useful, thank you very much 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.