?
Solved

retrieve computer's BIOS date with Delphi Pascal

Posted on 1997-08-15
7
Medium Priority
?
766 Views
Last Modified: 2012-08-14
How can i retrieve the computer's BIOS date with Delphi Pascal (16 bits version)?

I tried memory location Mem[$FFFF:$0005] but this gives a general protection failure

0
Comment
Question by:rj
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 

Author Comment

by:rj
ID: 1215425
Edited text of question
0
 

Expert Comment

by:sandburd
ID: 1215426
Hi,

With this little source i must work. The assembler routine gets the date. The other piece converts the date to a normal value, cause it's give in hexadecimal value's by the bios.
That's the default encoding that the bios uses for the value's, but there is a possibility that this is changed in the bios, the value's are given then binary. But i think that's not common.
I hope that this piece of code will help you.

Greetings,

Sandburd

------example code-------
var year,century,day,month:byte;
begin
 asm
    mov ah,04h
    int 1ah
    mov year,cl
    mov century,ch
    mov day, dl
    mov month, dh
 end;
 century:=(century div 16)*10 + century mod 16;
 Year:= (Year div 16)*10 +Year mod 16;
 day:=(day div 16)*10 +day mod 16;
 month:=(month div 16)*10 +month mod 16;

--------example code ends ----------
0
 

Author Comment

by:rj
ID: 1215429
Thanks for our answer.

I copied your routine to my Delhi project.
Unfortunately it does not work. I know my computer's BIOS date is 12-19-96. Your assembler routine however returns the date of today.

I hope you have another solution.

Bye, Robbert-Jan

0
New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

 
LVL 1

Accepted Solution

by:
sxh earned 800 total points
ID: 1215430
hi rj

i tried the usual way of reading the bios date address using the move(mem[$FFFF:$0005],myvar,8) and gpf'ed.

This is a real mode thing !

here is the working code to read the bios date from real mode low memory.

the program uses a single form with a button and label control.

hope this helps.

--------------cut here---------------------------------------
unit Bdate;

interface

uses
  SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  Forms, Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Label1: TLabel;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

function allocRealModePointer(var P: pointer; Size: longInt): boolean;
var
  Selector,
  base : word;
  LinearBase : longint;

begin
  result := false;
  LinearBase := MakeLong(0,hiword(longint(p)) shr 12) +
                hiword(longint(P)) shl 4 + loword(longint(P));

  Selector := AllocSelector(DSeg);
  base := SetSelectorBase(Selector, LinearBase);
  SetSelectorLimit(Selector, Size);
  if (Selector <> 0) and (base<>0) then
    begin
      P := Ptr(Selector, 0);
      result := true;
    end;
end;

function freeRealModePointer(var p: pointer): boolean;
var
  fr : Word;
begin
  fr := FreeSelector(hiword(longint(p)));
  if (fr=0) then begin
    p := nil;
    result := true;
  end else begin
    result := false;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  P: pChar;
begin
  P := Ptr($FFFF, $0005);
  if AllocRealModePointer(Pointer(p), 8) then
    begin
      Label1.Caption := StrPas(P);
      FreeRealModePointer(Pointer(P));
    end;
end;

end.

----------cut here----------------------------------------
0
 

Author Comment

by:rj
ID: 1215431
Thanks for your answer!
0
 
LVL 1

Assisted Solution

by:eviltekk
eviltekk earned 800 total points
ID: 1215427
try this thing:

procedure getbiosdate;
var time : datetime;
    unpacked : longint;
begin
unpacked:=ptr($FFFF,$0005)^;
unpacktime(unpacked,Time);
end;

now using time.month, time.year, time.day and time.dayofweek you can see the bios date.


0
 
LVL 1

Expert Comment

by:dark_wader
ID: 1215428
hey guys you don't have an idea how the protected mode workz...
you can't access it directly....
There were in BC7 some constants (or variables) that contained
system addrs so i suppose in DELPHI there should be tha same...
Or try to look thru WIN SDK help for some functions doing this

0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What's worse than having your data encrypted by ransomware? Getting attacked by a so-called "wiper," which simply destroys the data and offers you no hope of ever seeing it again.
The top devops trends for 2017 are focused on improved deployment frequency, decreased lead time for change and decreased MTTR.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question