Solved

Read BIOS and harddisk serial numbers

Posted on 1999-01-16
7
1,067 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
[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
  • 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 50 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
Independent Software Vendors: 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!

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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 this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Suggested Courses
Course of the Month5 days, 17 hours left to enroll

627 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