Hard disk serial no. 
Author Message
 Hard disk serial no.

I have one problem.

How can I get hard disk's serial number?

Thanks for help.

Vladimir Zderic



Sun, 09 May 1999 03:00:00 GMT
 Hard disk serial no.

On Wed, 20 Nov 1996 16:38:18 +0100, Vladimir Zderic

Quote:

>I have one problem.

>How can I get hard disk's serial number?

>Thanks for help.

>Vladimir Zderic

Hello.

If you in dos write DIR , then in the top after hardis's name there
come's a number,
on my hd it's the serial nr.

have a nice day

jan g kristensen




Sun, 09 May 1999 03:00:00 GMT
 Hard disk serial no.

Quote:
> I have one problem.

> How can I get hard disk's serial number?

> Thanks for help.

> Vladimir Zderic

Here's some stuff I captured from this forum on this subject:
************************************************************

I wrote a small unit that encapsulated most drive funtions including a
call to get a disk's serial number.  You can find it my home page at
http://summac.etcconnect.com/~fitco.  I will compile under Dephi 1.O but
not under 2.0.  Good luck.

-------------------------------------

Fitco: http://sumac.etcconnect.com/~fitco/

**********************************************************************

PROGRAM Serial (Input, Output);
USES CRT;

CONST
  HexDigits : ARRAY [0..15]OF CHAR = '0123456789ABCDEF';
TYPE
  InfoBuffer = RECORD
               InfoLevel : WORD;    {should be zero}
               Serial : LONGINT;
               VolLabel : ARRAY [0..10]OF CHAR;
               FileSystem : ARRAY [0..7]OF CHAR;
             END;
  SerString = STRING [9];

VAR
  IB : InfoBuffer;
  N : WORD;
  let : CHAR;
  param : STRING [10];
  IsSet : BOOLEAN;
  NewSerial : LONGINT;
  code : INTEGER;

  FUNCTION SerialStr (L : LONGINT) : SerString;
  VAR Temp : SerString;
  BEGIN
    Temp [0] := #9;
    Temp [1] := HexDigits [L SHR 28];
    Temp [2] := HexDigits [ (L SHR 24) AND $F];
    Temp [3] := HexDigits [ (L SHR 20) AND $F];
    Temp [4] := HexDigits [ (L SHR 16) AND $F];
    Temp [5] := '-';
    Temp [6] := HexDigits [ (L SHR 12) AND $F];
    Temp [7] := HexDigits [ (L SHR 8) AND $F];
    Temp [8] := HexDigits [ (L SHR 4) AND $F];
    Temp [9] := HexDigits [L AND $F];
    SerialStr := Temp;
  END;

  FUNCTION GetSerial (DiskNum : BYTE;
                     VAR I : InfoBuffer) : WORD;assembler;
    asm
    MOV AH, 69h
    MOV AL, 00h
    MOV BL, DiskNum
    PUSH DS
    LDS DX, I
    INT 21h
    POP DS

    XOR AX, AX

    END;

    FUNCTION SetSerial (DiskNum : BYTE;
                       VAR I : InfoBuffer) : WORD;assembler;
      asm
      MOV AH, 69h
      MOV AL, 00h
      MOV BL, DiskNum
      PUSH DS
      LDS DX, I
      INT 21h
      POP DS

      XOR AX, AX

      END;

      PROCEDURE ErrorOut (err : BYTE);
      BEGIN
        CASE err OF
          5 : BEGIN
              WRITELN ('Either the disk in ', let, ': is write',
                      'protected or it lacks an extended BPB.');
              WRITELN ('If the disk is not write-protected, ',
                      'reformat it with DOS 4 or higher.');
            END;
          15 : WRITELN ('Not a valid drive letter.');
          255 : BEGIN
                WRITELN ('SYNTAX:   SERIAL D:########"');
                WRITELN ('  where D: is the drive letter',
                        'and ######## is the eight digit');
                WRITELN ('  hexadecimal serial number with-',
                        'out the "-".');
                WRITELN ('EXAMPLE:  SERIAL A: 1234ABCD');
              END;

        ELSE WRITELN ('DOS ERROR #', N);
        END;
        HALT (1);
      END;

    BEGIN
      CLRSCR;
      IF PARAMCOUNT < 1 THEN ErrorOut (255);
      IF PARAMCOUNT > 2 THEN ErrorOut (255);
      param := PARAMSTR (1);
      CASE LENGTH (param) OF
        1 : {OK};
        2 : IF param [2] <> ':' THEN ErrorOut (255);
      ELSE ErrorOut (255);
      END;
      let := UPCASE (param [1]);
      IF (let < 'A') OR (let > 'Z') THEN ErrorOut (15);
      IF PARAMCOUNT < 2 THEN IsSet := FALSE
      ELSE
        BEGIN
          IsSet := TRUE;
          param := '$' + PARAMSTR (2);
          VAL (param, NewSerial, code);
          IF code <> 0 THEN ErrorOut (255);
        END;

      IF N = 0 THEN
        BEGIN
          WITH IB DO
            BEGIN
              WRITELN ('Serial Number is "',
                      SerialStr (Serial), '"');
              IF IsSet THEN
                BEGIN
                  Serial :=
                  NewSerial; ;
                  N :=

                  IF N = 0 THEN

                    WRITELN ('Successfully canged serial to "',
SerialStr (NewSerial), '"')
                  ELSE
                    ErrorOut (N);
                END;
            END;
        END
      ELSE ErrorOut (N);

    END.

John Atkins

********************************************************

Hope that helps!

----
RKR

****************************************

****************************************



Sun, 09 May 1999 03:00:00 GMT
 Hard disk serial no.



Quote:
> I have one problem.

> How can I get hard disk's serial number?

> Thanks for help.

> Vladimir Zderic

There is a Windows API call:

GetVolumeInformation

which can return all sorts of information about the hard disk, including
its serial number.

--
John Brady
Analyst/Programmer



Mon, 17 May 1999 03:00:00 GMT
 Hard disk serial no.

On Wed, 20 Nov 1996 16:38:18 +0100, Vladimir Zderic

Quote:

>I have one problem.
>How can I get hard disk's serial number?

procedure TForm1.Button2Click(Sender: TObject);
var
  SerialNum : dword;
  a, b : dword;
  Buffer  : array [0..255] of char;
begin

a, b, nil, 0) then
    Label1.Caption := IntToStr (SerialNum);
end;

-----------------------
Pekka Haapalainen

homepage: http://www.ttl.fi/personal/haapalainen.pekka



Mon, 17 May 1999 03:00:00 GMT
 Hard disk serial no.

This doesn't appear to work in Delphi 1.0. Any suggestions?

Quote:
>How can I get hard disk's serial number?

> procedure TForm1.Button2Click(Sender: TObject);
> var
>   SerialNum : dword;
>   a, b : dword;
>   Buffer  : array [0..255] of char;
> begin

> a, b, nil, 0) then
>     Label1.Caption := IntToStr (SerialNum);
> end;



Fri, 21 May 1999 03:00:00 GMT
 Hard disk serial no.

GetVolumeInformation is a Win32 call. For Delphi 1.0 you need to do some
backflips.  Here's the required code (portions from a TI by Borland):

type

  PRealModeRegs = ^TRealModeRegs;
  TRealModeRegs = record
    case Integer of
      0: (
        EDI, ESI, EBP, EXX, EBX, EDX, ECX, EAX: Longint;
        Flags, ES, DS, FS, GS, IP, CS, SP, SS: Word);
      1: (
        DI, DIH, SI, SIH, BP, BPH, XX, XXH: Word;
        case Integer of
          0: (
            BX, BXH, DX, DXH, CX, CXH, AX, AXH: Word);
          1: (
            BL, BH, BLH, BHH, DL, DH, DLH, DHH,
            CL, CH, CLH, CHH, AL, AH, ALH, AHH: Byte));
  end;

function RealModeInt(Int: Byte; var Regs: TRealModeRegs): Boolean;
{ procedure invokes int 31h function 0300h to simulate a real mode }
{ interrupt from protected mode. }
var
  ErrorFlag: Boolean;
begin
  asm
    mov ErrorFlag, 0       { assume success }
    mov ax, 0300h          { function 300h }
    mov bl, Int            { real mode interrupt to execute }
    mov bh, 0              { required }
    mov cx, 0              { stack words to copy, assume zero }
    les di, Regs           { es:di = Regs }
    int 31h                { DPMI int 31h }


    mov ErrorFlag, 1       { return false on error }

  end;
  Result := not ErrorFlag;
end;

function GetVolSerNo(Drive: TDriveChar): LongInt;
type
  PDiskInfo = ^TDiskInfo;
  TDiskInfo = record
    InfoLevel: Word;
    DiskSerNum: LongInt;
    VolumeLabel: array[0..10] of Byte;
    FileSysType: array[0..7] of Byte;
  end;
var
  L: LongInt;
  P: PDiskInfo;
  R: TRealModeRegs;
begin
  Result := 0;
  L := GlobalDOSAlloc(SizeOf(TDiskInfo));
  if L <> 0 then
  try
    P := Ptr(LoWord(L),0);
    FillChar(P^,sizeof(TDiskInfo),0);
    FillChar(R,sizeof(R),0);
    with R do
    begin
      AX := $6900;
      BL := Ord(Drive)-64;
      BH := 0;
      DS := HiWord(L);
      DX := 0;
    end;
    if RealModeInt($21,R) then
      Result := P^.DiskSerNum
  finally
    GlobalDosFree(LoWord(L));
  end;
end;



Quote:
> This doesn't appear to work in Delphi 1.0. Any suggestions?

> >How can I get hard disk's serial number?


> > a, b, nil, 0) then



Fri, 21 May 1999 03:00:00 GMT
 
 [ 7 post ] 

 Relevant Pages 

1. Hard Disk Serial Number

2. API for the hard disk label and serial number

3. MACINTOSH - Foxpro routine to grab hard disk serial #

4. Volume serial number of a hard disk

5. Obtaining Hard Disk Serial Number

6. Disk Array v/s hard Disk

7. new SCSI Hard disk problem non-Sun disk

8. I am having a problem with a hard disk drive or floppy disk drive

9. Hard disk serial number or Ethernet card serial number.

10. Run DTS from Hard Disk

11. Hard disk partitions

12. Backup to a remote hard disk


 
Powered by phpBB® Forum Software