[fpc-pascal]Getting disk label and serial numbers

XHajT03 at mbox.vol.cz XHajT03 at mbox.vol.cz
Thu Aug 8 22:08:52 CEST 2002


Date sent:      	Thu, 08 Aug 2002 14:44:19 -0400
From:           	Rolf Grunsky <rgrunsky at sympatico.ca>
To:             	Free Pascal List <fpc-pascal at deadlock.et.tudelft.nl>
Subject:        	[fpc-pascal]Getting disk label and serial numbers
Send reply to:  	fpc-pascal at deadlock.et.tudelft.nl

> I am currently trying to write a catalog program for my archive
> CD-ROM's and I can not find a working method of a) getting the volume
> label and b) getting the serial number.
> I am looking for a method that will work with both Win32 and OS/2.
.
.

 I suspect the only method working on both platforms is using IFDEF 
directive here (or a function with IFDEF directive inside ;-) ). I 
can't help with Win32, but for OS/2 it might look like:

***
program QueryFS;

uses
 DosCalls;

var
 I: TFSInfo;
 RC: longint;
 N: byte;
 C: char;
 S: string;

begin
 if ParamCount = 0 then
 begin
  WriteLn ('Disk letter expected!');
  Halt (1);
 end;
 S := ParamStr (1);
 C := Upcase (S [1]);
 N := Ord (C) - 64;
 WriteLn ('Working on ', C, ':');
 RC := DosQueryFSInfo (N, 2, I, SizeOf (I));
 if RC <> 0 then
  WriteLn ('Error ', RC, ' while obtaining volume information.') else
 begin
  WriteLn ('Volume label is "', I.VolumeLabel, '"');
  WriteLn ('Serial number is ', cardinal (I.Label_Date) shl 16 + 
I.Label_Time);
 end;
end.
***

 You'll probably want to convert the serial number to hexadecimal 
(it's shown as decimal here).

> And for a related project, where can I find a Pascal implementation of
> the MD5 secure hash?

 There's a unit md5 in FPC packages (/packages/base/md5 in CVS). It's 
a fairly new addition there, so it wasn't distributed with any 
release yet (it should appear in snapshots).

Tomas





More information about the fpc-pascal mailing list