Solved

retrieve computer's BIOS date with Delphi Pascal

Posted on 1997-08-15
7
740 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

In this article, I will show you HOW TO: Install VMware Tools for Windows on a VMware Windows virtual machine on a VMware vSphere Hypervisor 6.5 (ESXi 6.5) Host Server, using the VMware Host Client. The virtual machine has Windows Server 2016 instal…
What is Backup? Backup software creates one or more copies of the data on your digital devices in case your original data is lost or damaged. Different backup solutions protect different kinds of data and different combinations of devices. For e…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

757 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now