?
Solved

Read BIOS and harddisk serial numbers

Posted on 1999-01-16
7
Medium Priority
?
1,069 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 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

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 I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

719 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