🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.programming
Article #216

Re: Numer seryjny HDD

#216
From: ar... Marcin
Date: Mon, 29 Jan 1996 00:00
153 lines
4761 bytes
Grzegorz Szyszlo <ZN...@avalon.wbc.lublin.pl> wrote:

>Rafal Siejca <rsi...@zodiac19.mimuw.edu.pl> wrote:
>>
>>
>>On 22 Jan 1996, Tomasz Frontczak wrote:
>>
>>> Moze ktos wie jak programowo w Pascalu lub C odczytac numer seryjny
>>> twardego dysku.
>>> Prosze o informacje.

>proponuje na liste :) mysle ze wiecej osob byloby zainteresowanych. (ja tak)
>-- 

Maly prezencik:

   NUMBER  :  1759
  PRODUCT  :  Pascal
  VERSION  :  All
       OS  :  DOS
     DATE  :  December 13, 1995                       

    TITLE  :  Getting and setting a disks serial number



The following program shows how to read and write the serial
number on a disk drive. It uses interrupt $21 function $69
and reads the information back and forth into a record with
the following declaration:

  TSerPacket = record
    Info:Word;
    SerNo: Longint;
    Vol: Array[1..11] of char;
    FileType: Array[1..8] of char;
  end;

The first word of the above record should always contain
zero, the second contains the serial number, the third
the volume label and the fourth the FileType, which is usually
either FAT 16 or FAT 12.

When setting a new serial number, the programs first reads the
current information, and then sets the new serial number
and writes it to disk.

The code shown below provides the user with three functions:

  GetSerialInfo: Get the current serial number
  SetSerialInfo: Set a new serial number
  DisplaySerialInfo: Display the information in the current
                     variable of type TPacket.

Notice that DisplaySerialInfo does not write information
to a disk drive, but only displays that information to
the user via the screen. All of these routines depend
on a global variable of type TSerPacket, which is called
SPacket. It makes no sense to call DisplaySerialInfo
before calling GetSerialInfo.

The drive specification is passed as a number, where
the default drive is zero, drive A is one, drive
B is two, etc.


program SetDiskSer;

{$A+,B-,D+,E+,F-,G+,I+,L+,N-,O-,P-,Q-,R-,S-,T-,V+,X+,Y+}
{$M 16384,0,655360}

type
  TSerPacket = record
    Info:Word;        { Info level always zero }
    SerNo: Longint;   { Disk }
    Vol: Array[1..11] of char;
    FileType: Array[1..8] of char;
  end;

var
  SPacket: TSerPacket;

function GetSerialInfo(Drive: Byte): Byte; assembler;
asm
  mov ah, 69h
  mov al, 0  { This is where you 1 set serial, 0 to get serial
               number }
  mov bl, 1  { drive number 0 = default, 1 = A, 2 = B , 3 = C }
  mov dx, offset [SPacket]
  int 21h
end;


function SetSerialInfo(Drive: Byte; SerNo: LongInt): Boolean;
var
  S: String;
begin
  GetSerialInfo(Drive);
  SPacket.SerNo := SerNo;
  asm
    mov ah, 69h
    mov al, 1  { This is where you 1 set serial, 0 to get serial
                 number }
    mov bl, Drive  { drive number 0 = default, 1 = A, 2 = B ,
                     3 = C }
    mov dx, offset [SPacket]
    int 21h
  end;
end;

procedure DisplaySerialInfo;
var
  S: String;
begin
  WriteLn('Info level: ', SPacket.Info);
  WriteLn('Serial Num: ', SPacket.SerNo);
  FillChar(S, SizeOf(S), #0);
  Move(SPacket.Vol[1], S[1], 11);
  S[0] := #11;
  WriteLn('Vol: ', S);
  FillChar(S, SizeOf(S), #0);
  Move(Spacket.FileType,S[1], 8);
  S[0] := #8;
  WriteLn('Type: ', S);
end;

begin
  SetSerialInfo(1, 12);  { One means Drive A, 16 is the serial
                           number }
  GetSerialInfo(1);
  DisplaySerialInfo;
  ReadLn;
end.


DISCLAIMER: You have the right to use this technical information
subject to the terms of the No-Nonsense License Statement that
you received with the Borland product to which this information
pertains.


Pozdrawiam 
Marcin


*************************************************************
* Marcin Szumiela  * ART4 Comp Group *   Where any view     *
* ar...@pdi.lodz.pl * PC&AMIGA progr. * of Money exists Art  *
*------------------*-----------------* cannot be carried on.*
*     http://www.pdi.net/~art4       *        William Blake *
*************************************************************
* Private ArtGallery: http://www.pdi.net/~art4/gallery.html *
*************************************************************
Technical Details
Message-ID: <4ejlq3$lpc@polonez.man.lodz.pl>
Path: mbox-mo1.pugleaf.net!unknown!not-for-mail
References: <4e0096$hm1@sun1000.pwr.wroc.pl> <Pine.LNX.3.91.960123095749.151E-100000@zodiac19.mimuw.edu.pl> <4ej2b0$996@priam.umcs.lublin.pl>

Show Full Headers
Complete Article Headers
From: ar...@pdi.net (Marcin)
Subject: Re: Numer seryjny HDD
Date: 1996/01/29
Message-ID: <4ejlq3$lpc@polonez.man.lodz.pl>
X-Deja-AN: 137068002
references: <4e0096$hm1@sun1000.pwr.wroc.pl> <Pine.LNX.3.91.960123095749.151E-100000@zodiac19.mimuw.edu.pl> <4ej2b0$996@priam.umcs.lublin.pl>
organization: ART4 Comp Group
reply-to: ar...@pdi.net
newsgroups: pl.comp.programming
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit