Solved

retrieve computer's BIOS date with Delphi Pascal

Posted on 1997-08-15
7
746 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
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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
LVL 1

Accepted Solution

by:
sxh earned 200 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 200 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to load a ClientDataSet in Delphi from a Resource file? 4 1,318
Delphi need modify hand cursor windows 4 560
delphi prevent click fast 2 215
find a node in VST 2 68
An article on effective troubleshooting
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

785 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