Link to home
Start Free TrialLog in
Avatar of pr2501
pr2501

asked on

Code for check BIOS on any Windows OS and also 64-bit addresses memory PCs

Code which i have now works on  Bios of my PC (windows XP 32-bit memory PC) and it gives me  next:
(*HWRec3.CommaText :='SystemBIOSVersionLine1=PTLTD-6...., SystemBIOSVersionLine2=Version6.00R1.11......A1, SystemBIOSVersionLine3=Version6.00R1.11......A1, SystemBIOSVersionLine4=Version6.00R1.11......A1,'+
'SystemBIOSDate=03/18/08, VideoBIOSVersionLine1=HardwareVersion0.0, VideoBIOSDate=03/08/20';  

Open in new window


How can i get the same with any windows OS and 64-bit addresses memory PCs?
Avatar of Beneford
Beneford
Flag of United Kingdom of Great Britain and Northern Ireland image

Two approaches:

1. Use the registry:
HKLM\Hardware\DESCRIPTION\System
HLMK\Hardware\DESCRIPTION\System\BIOS

2. Use WMI
i. via command line:
wmic bios get *
ii. via COM API
There's a blog article on this: http://theroadtodelphi.wordpress.com/2011/04/21/accesing-the-wmi-from-delphi-and-fpc-via-com-without-late-binding-or-wbemscripting_tlb/
iii. via WBEM Scripting
Check out (especially the answers): http://stackoverflow.com/questions/10199531/how-can-i-improve-the-wmi-performance-using-delphi
Avatar of pr2501
pr2501

ASKER

Thank you.
Can i get code for form with TMemo and button to write BIOS into memo?
( for 64 bit PC also)

Pleas.
This should work on 64bit and 32bit - no changes.
procedure TForm1.Button1Click(Sender: TObject);

  procedure getRegValues(sl:TStrings;Key:string);
  var aRegistry:TRegistry;
  var vl:TStrings;
  var i:integer;
  begin
      aRegistry:=TRegistry.Create;
      aRegistry.RootKey:=HKEY_LOCAL_MACHINE;
      if aRegistry.OpenKeyReadOnly(Key) then begin
         vl:=TStringList.Create;
         aRegistry.GetValueNames(vl);
         for i := 0 to vl.Count-1 do begin
             case aRegistry.GetDataType(vl[i]) of
                  rdString:
                      sl.Add(vl[i]+': '+aRegistry.ReadString(vl[i]));
                  rdInteger:
                      sl.Add(vl[i]+': '+inttostr(aRegistry.ReadInteger(vl[i])));
                  end;
             end;
         vl.Free;
         end;
      aRegistry.Free;
  end;

begin
     Memo1.Lines.clear;
     getRegValues(Memo1.Lines,'\Hardware\DESCRIPTION\System');
     getRegValues(Memo1.Lines,'\Hardware\DESCRIPTION\System\BIOS');
end;

Open in new window

Avatar of pr2501

ASKER

getRegValues(Memo1.Lines,'\Hardware\DESCRIPTION\System');
Gives me :
Identifier: AT/AT COMPATIBLE
SystemBiosDate: 09/12/08
BootArchitecture: 18
PreferredProfile: 2
Capabilities: 49837
VideoBiosDate: 05/02/07

getRegValues(Memo1.Lines,'\Hardware\DESCRIPTION\System\BIOS');
Here i do not get anything?

Why?


And on another PC i get just next 3 lines:

Identifier: ..................
SystemBiosDate: .............
VideoBiosDate: ...............
Have you looked under RegEdit to see what keys and values are actually there?
It's possible they keys/value have different names, and you'll need to check a few computers to see for sure.  I only tried a couple that I have here, and they're not particularly old.
Looking at an old XP SP3 system, the System\BIOS key is missing, which explains your behaviour. It's entirely possible that even older OSs will have other keys missing.

You may need to opt for a hybrid approach where you use one technique for older OSs and this one for the newer OSs. Presumably, the OS that's not working is OK on your old technique?
Avatar of pr2501

ASKER

1.
Your code can not see REG_MULTI_SZ type (systembiosversion).
What must i do to see all types?
Avatar of pr2501

ASKER

Thank you.
ASKER CERTIFIED SOLUTION
Avatar of Beneford
Beneford
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial