delphi3000.com - the free delphi knowledge platform
delphi3000.com - the free delphi knowledge platform
494 Users Online NOW
Have a look at your member-status

connecting people's knowledge


  - Recent ArticlesRSS feed for Recent Articles on delphi3000.com
  - List of All Articles
  - Top Viewed Articles
  - Articles (+Attachem.)
  - Articles Of Interest
  - Categories
  - Top Uploader
  - Search
  - Index

  - My Home
  - Submit an Article
  - My Articles
  - My Personal Data
  - My Bookmarks
  - Activities
  - Login/Logout

  - Sign Up
  - Why Sign Up
  - Newsletter

  - Press
  - Advertise

  - Contact
  - Feedback





Community
Borland
ClubeDelphi
Dr. Bob
UK-BUG
Delphi Meetings
Planeta Delphi







Startblatt.de






Share this article with friendsShare this article with friends
Rate this articleRate this article - to keep the quality of delphi3000.com !
Comment this article or read through previous comments (2)


How can I get BIOS date and version under Win 9X/ME/NT/2000/XP of Windows?Format this article printer-friendly!Bookmark function is only available for registered users!
(how to read multi-string values from the registry)
Product:
Delphi 5.x (or higher)
Category:
System
Skill Level:
Scoring:
Last Update:
10/10/2001
Search Keys:
delphi delphi3000 article borland vcl code-snippet BIOS date version Windows-NT Windows-2000 Windows-XP
Times Scored:
10
Visits:
10937
Uploader: George Stephanov
Company:
Reference: N/A
 
Question/Problem/Abstract:
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 < bufsize do
    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.





Please rate this article!
Skill level:
BeginnerExpert

Useful:
No!Very!

Overall rating:
PoorExcellent



Comments to this article
Write a new comment
It doesn't function under Windows 2000
    Ricardo Maroquio Bernardo (Mar 1 2002 8:45PM)

This method didn't function under windows 2000. The registry key SystemBiosVersion doesn't exists.
Respond

RE: It doesn't function under Windows 2000
George Stephanov (Mar 2 2002 10:29AM)

Thanks for pointing this out. If you know the key in which BIOS version could be found under Win2000 you can tell me and I'll correct the article.

Respond














 
Sign up to consume product discounts for Bronze memberships !

read more


  Visit our Sponsor

 

  Community Ad of
D. Wischnewski
 
   














 







     
  Copyright © 2000 - 2007 delphi3000.com - All rights reserved. Terms of use. || Privacy
delphi3000.com is a service by bluestep.com IT-Services GmbH (Vienna)