Solved

Read BIOS and harddisk serial numbers

Posted on 1999-01-16
7
1,053 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 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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

762 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

17 Experts available now in Live!

Get 1:1 Help Now