Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

retrieve computer's BIOS date with Delphi Pascal

Posted on 1997-08-15
7
Medium Priority
?
775 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
Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

 
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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

What monsters are hiding in your child's room? In this article I will share with you a tech horror story that could happen to anyone, along with some tips on how you can prevent it from happening to you.
Article by: evilrix
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data defin…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

596 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