Solved

retrieve computer's BIOS date with Delphi Pascal

Posted on 1997-08-15
7
752 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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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.

 
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

Suggested Solutions

This article describes my battle tested process for setting up delegation. I use this process anywhere that I need to setup delegation. In the article I will show how it applies to Active Directory
The business world is becoming increasingly integrated with tech. It’s not just for a select few anymore — but what about if you have a small business? It may be easier than you think to integrate technology into your small business, and it’s likely…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

830 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