Title: How can I get BIOS date and version under Win 9X/ME/NT/2000/XP of Windows?
Question: If you want to get BIOS date and version in Windows NT/2000/XP you've gonna have problems.
Answer:
Sometimes you might want to get BIOS date and version of the BIOS to use it
to create some protection for your program. Under Windows 9X it is very easy
to do that. Here's an example:
procedure GetBiosInfo (var Name, Copyright, Info, Date: string);
const BiosName = $FE061;
BiosCopyright = $FE091;
BiosInfo = $FEC71;
BiosDate = $FFFF5;
begin
try
Name := string (PChar (Ptr (BiosName)));
except
Name := '';
end;
try
Copyright := string (PChar (Ptr (BiosCopyright)));
except
Copyright := '';
end;
try
Info := string (PChar (Ptr (BiosInfo)));
except
Info := '';
end;
try
Date := string (PChar (Ptr (BiosDate)));
except
Date := '';
end;
end;
But under Windows NT/2000/XP you've gonna have problems with this procedure
because the address space of the bios is protected by the OS an every time you
try to access these addresses an exception will be thrown. Happily you can
find BIOS date and vesion in the registry(this is valid for Win 9X/ME too but
the registry key is different). It is easy to obtain date from the registry
but you've gonna have some problems reading the version information because it
is stored as multi-string value (something like multirow string) which is not
supported by TRegistry class. You can still get it as binary value and with
little effort convert it to string list. I've done it for you. Here's an
example:
//this is the method which gets multi-string values from the registry
//and converts them to TStringlist
function ReadMultirowKey(reg: TRegistry; Key: string): TStrings;
const bufsize = 100;
var
i: integer;
s1: string;
sl: TStringList;
bin: array[1..bufsize] of char;
begin
try
result := nil;
sl := nil;
sl := TStringList.Create;
if not Assigned(reg) then
raise Exception.Create('TRegistry object not assigned.');
FillChar(bin,bufsize,#0);
reg.ReadBinaryData(Key,bin,bufsize);
i := 1;
s1 := '';
while i begin
if ord(bin[i]) = 32 then
s1 := s1 + bin[i]
else
begin
if Length(s1) 0 then
begin
sl.Add(s1);
s1 := '';
end;
end;
inc(i);
end;
result := sl;
except
sl.Free;
raise;
end;
end;
//this is an example of getting BIOS info from the registry
//under Windows NT/2000/XP
procedure TBIOSInfo.GetRegInfoWinNT;
var
Registryv : TRegistry;
RegPath : string;
sl : TStrings;
begin
Params.Clear;
RegPath := '\HARDWARE\DESCRIPTION\System';
registryv:=tregistry.Create;
registryv.rootkey:=HKEY_LOCAL_MACHINE;
sl := nil;
try
registryv.Openkey(RegPath,false);
ShowMessage('BIOS Date: '+RegistryV.ReadString('SystemBIOSDate'));
sl := ReadMultirowKey(RegistryV,'SystemBIOSVersion');
ShowMessage('BIOS Version: '+sl.Text);
except
end;
Registryv.Free;
if Assigned(sl) then sl.Free;
end;
Now when you know how to get BIOS date and version under all kinds of windows
you must only make a function which recognises the version of Windows currentry
running and use one of the two methods to obtain these values. This could
be easily done using JEDI Component Library's function IsWinNT or using the
standard windows API funstion GetVersionEx.