{***********************************************************************}
{									}
{ __RetVlFil  Return the volume label					}
{									}
{ function  __RetVlFil(Drive : char; var VolStamp : integer) : string	}
{									}
{	      Drive	The drive whose volume	label is returned.	}
{	      VolStamp	The date and time of last modification of the	}
{			volume if it is found.	These values are for-	}
{			matted as standard directory date/stamp 	}
{			entries, and can be converted to integers	}
{			representing hours, mins, etc. using the	}
{			procedure UnPackTime.				}
{									}
{ Description __RetVlFil returns the volume label for the specified	}
{	      drive.  If the volume label cannot be found (it either	}
{	      does not exist or the drive does not exist), the NULL	}
{	      string is returned.					}
{									}
{ Version     4.00 (C)Copyright Blaise Computing Inc.  1987		}
{_______________________________________________________________________}

function __RetVlFil(Drive : char; var VolStamp : longint) : string;

  var
    ExtendedFcb : array[-7..36] of byte; { Extended File Control Block	}
    DTAPtr	: pointer;		 { Pointer to Disk Transfer Area}
    TempDTA	: array[0..44] of byte;
    DriveNo	: byte;
    VolName	: string;
    Reg 	: registers;

  begin {__RetVlFil}

    { The current DTA must be saved and a new one established, because	}
    { the DOS function used ($11) uses the DTA. 			}

    DTAPtr  := __RetDTFil;
    __SetDTFil(@TempDTA);

    DriveNo := byte(Upcase(Drive)) - byte('A') + 1;

    { Set up the extended file control block for a call to DOS function }
    { $11, search for any entry with an attribute of 8 (volume label).	}

    ExtendedFcb[-7] := $FF;	       { This is an extended FCB	}
    ExtendedFcb[-1] := $08;	       { Attribute 8 = volume label	}
    ExtendedFcb[0]  := DriveNo;
    FillChar(ExtendedFcb[1],11,$3F);   { Search on '???????? ???'	}
    FillChar(ExtendedFcb[12],25,0);    { Reset the rest to zeros	}

    with Reg do
      begin
	AH := $11;
	DS := Seg(ExtendedFcb);
	DX := Ofs(ExtendedFcb);
	Intr(_DOS,Reg);
	if (AL = $FF) then	       { Volume label was not found	}
	   begin
	     VolStamp	:= 0;
	     __RetVlFil := ''
	   end
	else			       { Information was found and put	}
	   begin		       { in the disk transfer area.	}
	     Move(TempDTA,ExtendedFcb[-7],39);	{ Now the FCB has the  }
	     Move(ExtendedFcb[1],VolName[1],11);{ the information.	}
	     VolName[0] := #11;
	     __RetVlFil := VolName;
	     Move(ExtendedFcb[23],VolStamp,4);
	   end
      end;

      __SetDTFil(DTAPtr)	       { Return the previous DTA	}

  end;	{__RetVlFil}
