Answer» I have a function to get BIOS information, for exapmple BIOS serial number as String. I USE this solution (found it in internet) :
Code: [Select]function SerialNumber: string; const sQuery = 'select SerialNumber from Win32_BIOS'; var Item: SWbemObject; NumProp: LongWord; ObjectSet: ISWbemObjectSet; OleProperty: OleVariant; begin ObjectSet := CoSWbemLocator.Create.ConnectServer( '', 'root\cimv2', '', '', '', '', 0, nil ).ExecQuery( sQuery, 'WQL', wbemFlagBidirectional, nil ); if Succeeded( ( ObjectSet._NewEnum as IEnumVariant ).Next( 1, OleProperty, NumProp ) ) and ( NumProp > 0 ) and Succeeded( IDispatch( OleProperty ).QueryInterface( SWBemObject, Item ) ) then begin Result := Item.GetObjectText_(0); end else begin Result := '<Unknown>'; end; end; So, it works unless I terminate the application. Then I get an "access violation" message. I deciced to use another code :
Code: [Select]BIOSSerialNumber := string(PCHAR(Ptr($FEC71)));
Then "access violation" COMES at the beginning before Application.Run
My problem appears only in Windows 2000. For the first code I'm pretty SURE the problem is with ExecQuery() function, but I don't know how to fix it...
|