Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Read BIOS and harddisk serial numbers

Posted on 1999-01-16
7
Medium Priority
?
1,074 Views
Last Modified: 2008-02-20
Delphi:
How can read the Bios and harddisk serial numbers ?
I can find a component for these ?
0
Comment
Question by:ginsonic
  • 4
  • 3
7 Comments
 
LVL 9

Author Comment

by:ginsonic
ID: 1362233
Edited text of question
0
 
LVL 17

Expert Comment

by:inthe
ID: 1362234
http://www.experts-exchange.com/Q.10108781
for harddisk
Regards Barry
0
 
LVL 17

Accepted Solution

by:
inthe earned 200 total points
ID: 1362235
this site is were to go:
http://www.bhnet.com.br/~simonet/
   under ASomnitools     {delphi 4 }
or under ASpowertools { delphi 3}

TASSysInfo is the component name and it will do everything you need including bios serial no + lots more
Regards Barry
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 9

Author Comment

by:ginsonic
ID: 1362236
Sorry , but I can find the Bios s.n. .
The component is cool , but I need Bios s.n. to protect my programme .
Maybe I don't search the good component , but ASPowerTools don't have Bios s.n. option , only hard disk s.n. .
Can you tell me more ?

Best regards ,
Nick
0
 
LVL 17

Expert Comment

by:inthe
ID: 1362237
First -sorry i thought it did retrieve bios s/n
Second -here's more info
The MB/Bios S/N is not unique,it is only a batch number. Several boards  have the same number if they
-have the same manufacturer.
- have the same revision level
- have the same BIOS date and BIOS model (eg. AMI, Award, Phoenix, Mr. BIos,etc. )So if you were installing your software at a company who purchased there pc's in batch it is possible they will have the same s/n.it would also be extrmely difficult  to get this batch number,probably the best thing is to get motherboard s/n as well as hard disk s/n with other info and combine them.the hard disk number is set when the disk is formatted based on the time and it is not likely 2 people are formatting there disks at identical times.
the best number to get would be the "mac address" (pc's network ethernet address) as in nearly all cases it is unique but then only if the pc's are on a network.
i post some code below for what is possible to read from the cmos it was wrote by Earl Glynn of efg's computer lab
http://infomaster.net/external/efg

Here's a Delphi 3 example that fetches some of the CMOS information and gets
the date and time using the "old" BIOS interrupts.  (This was adapted from
some old TP 7 code, so I didn't bother using "newer" Delphi functions for
conversions.)


unit ScreenCMOS;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, Spin;

type
  TForm1 = class(TForm)
    ButtonCMOSInfo: TButton;
    Memo1: TMemo;
    ButtonReadClock: TButton;
    SpinEditCentury: TSpinEdit;
    SpinEditYear: TSpinEdit;
    SpinEditMonth: TSpinEdit;
    SpinEditHours: TSpinEdit;
    SpinEditMinutes: TSpinEdit;
    SpinEditSeconds: TSpinEdit;
    SpinEditDay: TSpinEdit;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    ButtonSetClock: TButton;
    procedure ButtonCMOSInfoClick(Sender: TObject);
    procedure ButtonReadClockClick(Sender: TObject);
    procedure ButtonSetClockClick(Sender: TObject);
  private
    PROCEDURE CMOSSummary;
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;


implementation
{$R *.DFM}

////////////////////////////////////////////////////////////////////////////

  //  Note:  PortIn and PortOut will work in Windows 95, but will NOT work
  //         under Windows NT.

  FUNCTION PortIn(IOport:  WORD):  BYTE;  ASSEMBLER; REGISTER;
  ASM
    MOV    DX,AX
    IN     AL,DX
  END;


  PROCEDURE PortOut(IOport:  WORD;  Value:  BYTE);  ASSEMBLER; REGISTER;
  ASM
     XCHG   DX,AX
     OUT    DX,AL
  END;

////////////////////////////////////////////////////////////////////////////

  FUNCTION B2X(CONST b:  BYTE):  STRING;  {byte-to-hexadecimal}
    CONST HexDigit:  ARRAY[0..15] OF CHAR = '0123456789ABCDEF';
  BEGIN
    RESULT :=  HexDigit[b SHR 4] + HexDigit[b AND $0F]
  END {B2X};


  FUNCTION C2X(CONST s:  STRING):  STRING;  {character-to-hexadecimal}
    VAR
      i:  BYTE;
      t:  STRING;
  BEGIN
    t := '';
    FOR i := 1 TO LENGTH(s) DO
    BEGIN
      AppendStr(t, B2X( BYTE(s[i]) ));
    END;
    RESULT := t
  END {C2X};


  PROCEDURE TForm1.CMOSsummary;
    VAR
      i,j,k:  BYTE;
      line :  STRING[16];
      hex  :  STRING[32];
  BEGIN
    Memo1.Lines.Add('CMOS RAM Memory');
    Memo1.Lines.Add ('   . . . . | . . . . | . . . . | .
..|....|....|.');
    k := 0;
    FOR j := 1 TO 4 DO BEGIN
      line := '';
      FOR i := 1 TO 16 DO BEGIN
        PORTOut($70,k);
        line := line + CHR(PORTIn($71));
        INC (k);
      END;
      hex := C2X(line);
      FOR i := 1 TO 16 DO
        IF   NOT (line[i] IN [#$20..#$7E])
        THEN line[i] := '.';           {an 'unprintable' character}
      Memo1.Lines.Add ('  ' + hex + '  ' + line)
    END
  END;


procedure TForm1.ButtonCMOSInfoClick(Sender: TObject);
begin
  CMOSSummary
end;


FUNCTION BCDToInt(bcd:  BYTE):  INTEGER;
BEGIN
  RESULT := 10*(bcd SHR 4) + (bcd AND $0F)
END;


FUNCTION IntToBCD(i:  INTEGER):  BYTE;
BEGIN
  RESULT := 16*(i DIV 10) + (i MOD 10)
END;



// See IBM ROM BIOS by Ray Duncan, Microsoft Press, 1988
PROCEDURE GetCMOSDate(VAR Day, Month, Year, Century:  BYTE);  PASCAL;
BEGIN
  // All values returned are BCD -- binary-coded decimal
  asm
    MOV AH,$04
    INT $1A        // BIOS Call:  Read date from real-time clock

    MOV EAX,Century
    MOV [EAX],CH

    MOV EAX,Year
    MOV [EAX],CL

    MOV EAX,Month
    MOV [EAX],DH

    MOV EAX,Day
    MOV [EAX],DL
  end;

  // Convert from BCD to binary
  Century := BCDToInt(Century);
  Year := BCDToInt(Year);
  Month := BCDToInt(Month);
  Day := BCDTOInt(Day)
END;

Regards Barry



0
 
LVL 17

Expert Comment

by:inthe
ID: 1362238
sorry i missed half out here is full unit:

unit ScreenCMOS;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, Spin;

type
  TForm1 = class(TForm)
    ButtonCMOSInfo: TButton;
    Memo1: TMemo;
    ButtonReadClock: TButton;
    SpinEditCentury: TSpinEdit;
    SpinEditYear: TSpinEdit;
    SpinEditMonth: TSpinEdit;
    SpinEditHours: TSpinEdit;
    SpinEditMinutes: TSpinEdit;
    SpinEditSeconds: TSpinEdit;
    SpinEditDay: TSpinEdit;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    ButtonSetClock: TButton;
    procedure ButtonCMOSInfoClick(Sender: TObject);
    procedure ButtonReadClockClick(Sender: TObject);
    procedure ButtonSetClockClick(Sender: TObject);
  private
    PROCEDURE CMOSSummary;
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;


implementation
{$R *.DFM}

////////////////////////////////////////////////////////////////////////////

  //  Note:  PortIn and PortOut will work in Windows 95, but will NOT work
  //         under Windows NT.

  FUNCTION PortIn(IOport:  WORD):  BYTE;  ASSEMBLER; REGISTER;
  ASM
    MOV    DX,AX
    IN     AL,DX
  END;


  PROCEDURE PortOut(IOport:  WORD;  Value:  BYTE);  ASSEMBLER; REGISTER;
  ASM
     XCHG   DX,AX
     OUT    DX,AL
  END;

////////////////////////////////////////////////////////////////////////////

  FUNCTION B2X(CONST b:  BYTE):  STRING;  {byte-to-hexadecimal}
    CONST HexDigit:  ARRAY[0..15] OF CHAR = '0123456789ABCDEF';
  BEGIN
    RESULT :=  HexDigit[b SHR 4] + HexDigit[b AND $0F]
  END {B2X};


  FUNCTION C2X(CONST s:  STRING):  STRING;  {character-to-hexadecimal}
    VAR
      i:  BYTE;
      t:  STRING;
  BEGIN
    t := '';
    FOR i := 1 TO LENGTH(s) DO
    BEGIN
      AppendStr(t, B2X( BYTE(s[i]) ));
    END;
    RESULT := t
  END {C2X};


  PROCEDURE TForm1.CMOSsummary;
    VAR
      i,j,k:  BYTE;
      line :  STRING[16];
      hex  :  STRING[32];
  BEGIN
    Memo1.Lines.Add('CMOS RAM Memory');
    Memo1.Lines.Add ('   . . . . | . . . . | . . . . | .
..|....|....|.');
    k := 0;
    FOR j := 1 TO 4 DO BEGIN
      line := '';
      FOR i := 1 TO 16 DO BEGIN
        PORTOut($70,k);
        line := line + CHR(PORTIn($71));
        INC (k);
      END;
      hex := C2X(line);
      FOR i := 1 TO 16 DO
        IF   NOT (line[i] IN [#$20..#$7E])
        THEN line[i] := '.';           {an 'unprintable' character}
      Memo1.Lines.Add ('  ' + hex + '  ' + line)
    END
  END;


procedure TForm1.ButtonCMOSInfoClick(Sender: TObject);
begin
  CMOSSummary
end;


FUNCTION BCDToInt(bcd:  BYTE):  INTEGER;
BEGIN
  RESULT := 10*(bcd SHR 4) + (bcd AND $0F)
END;


FUNCTION IntToBCD(i:  INTEGER):  BYTE;
BEGIN
  RESULT := 16*(i DIV 10) + (i MOD 10)
END;



// See IBM ROM BIOS by Ray Duncan, Microsoft Press, 1988
PROCEDURE GetCMOSDate(VAR Day, Month, Year, Century:  BYTE);  PASCAL;
BEGIN
  // All values returned are BCD -- binary-coded decimal
  asm
    MOV AH,$04
    INT $1A        // BIOS Call:  Read date from real-time clock

    MOV EAX,Century
    MOV [EAX],CH

    MOV EAX,Year
    MOV [EAX],CL

    MOV EAX,Month
    MOV [EAX],DH

    MOV EAX,Day
    MOV [EAX],DL
  end;

  // Convert from BCD to binary
  Century := BCDToInt(Century);
  Year := BCDToInt(Year);
  Month := BCDToInt(Month);
  Day := BCDTOInt(Day)
END;


PROCEDURE SetCMOSDate(Day, Month, Year, Century:  BYTE);  PASCAL;
  VAR
    BCDDay    :  BYTE;
    BCDMonth  :  BYTE;
    BCDYear   :  BYTE;
    BCDCentury:  BYTE;
BEGIN
  BCDDay := IntToBCD(Day);
  BCDMonth := IntToBCD(Month);
  BCDYear := IntToBCD(Year);
  BCDCentury := IntToBCD(Century);

  asm
    MOV AH,$05
    MOV CH,BCDCentury
    MOV CL,BCDYear
    MOV DH,BCDMonth
    MOV DL,BCDDay
    INT $1A        // BIOS Call:  Set real-time clock date
  end
END;


PROCEDURE GetCMOSTime(VAR Hours, Minutes, Seconds, SavingsTime:  BYTE);
PASCAL;
BEGIN
  // All values returned are BCD -- binary-coded decimal
  asm
    MOV AH,$02
    INT $1A        // BIOS Call:  Read

    MOV EAX,Hours
    MOV [EAX],CH

    MOV EAX,Minutes
    MOV [EAX],CL

    MOV EAX,Seconds
    MOV [EAX],DH

    MOV EAX,SavingsTime
    MOV [EAX],DL
  end;

  Hours := BCDToInt(Hours);
  Minutes := BCDToInt(Minutes);
  Seconds := BCDToInt(Seconds);
  SavingsTime := BCDToInt(SavingsTime);
END;


PROCEDURE SetCMOSTime(Hours, Minutes, Seconds, SavingsTime:  BYTE);  PASCAL;
  VAR
    BCDHours      :  BYTE;
    BCDMinutes    :  BYTE;
    BCDSeconds    :  BYTE;
    BCDSavingsTime:  BYTE;
BEGIN
  BCDHours := IntToBCD(Hours);
  BCDMinutes := IntToBCD(Minutes);
  BCDSeconds := IntToBCD(Seconds);
  BCDSavingsTime := IntToBCD(SavingsTime);

  asm
    MOV AH,$03
    MOV CH,BCDHours
    MOV CL,BCDMinutes
    MOV DH,BCDSeconds
    MOV DL,BCDSavingsTime
    INT $1A        // BIOS Call:  Set real-time clock time
  end
END;


procedure TForm1.ButtonReadClockClick(Sender: TObject);
  VAR
    Century    :  BYTE;
    Day        :  BYTE;
    Hours      :  BYTE;
    Minutes    :  BYTE;
    Month      :  BYTE;
    SavingsTime:  BYTE;
    Seconds    :  BYTE;
    year       :  BYTE;
begin
  GetCMOSDate(Day, Month, Year, Century);
  GetCMOSTime(Hours, Minutes, Seconds, SavingsTime);

  Memo1.Lines.Add(
    IntToStr(Month) + '/' +
    IntToStr(Day) + '/' +
    IntToStr(100*Century + Year ) + '  ' +

    IntToStr(Hours) + ':' +
    IntToStr(Minutes) + ':' +
    IntToStr(Seconds) + '  Savings=' +
    IntToStr(SavingsTime));
end;

procedure TForm1.ButtonSetClockClick(Sender: TObject);
begin
  SetCMOSDate(SpinEditDay.Value,
              SpinEditMonth.Value,
              SpinEditYear.Value,
              SpinEditCentury.Value);

  SetCMOSTime(SpinEditHours.Value,
              SpinEditMinutes.Value,
              SpinEditSeconds.Value,
              0 {for savings time for now});  // use 1 for savings time
end;

end.

0
 
LVL 9

Author Comment

by:ginsonic
ID: 1362239
THANKS!

Keep in touch ,
Nick
nick@decebal.ro
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

877 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