home *** CD-ROM | disk | FTP | other *** search
- unit DosUtil;
- { DosUtil.Pas - Contains volume labeling functions for 16-bit Delphi. }
- { Copyright (c) 1996. All Rights Reserved. }
- { By Paul Kimmel. okemos, MI USA }
-
- interface
-
- Uses
- SysUtils, WinProcs;
- Type
- { Extended file control block. }
- X_FCB = record
- Extended : byte;
- Reserved : array[1..5] of byte;
- Attribute : byte;
- Drive : shortint;
- FileName : array[1..8] of char;
- Extension : array[1..3] of char;
- CurrentBlock : integer;
- RecordSize : integer;
- FileSize : Longint;
- DateCreated : integer;
- TimeCreated : integer;
- Reserved2 : array[1..8] of byte;
- CurrentRecord : byte;
- Random : Longint;
- end;
-
-
- Function SetLabel( LabelName : string ) : integer;
- Function GetLabel( Drive : string ) : string;
- Function ClearLabel( Drive : string ) : integer;
-
- implementation
-
- const
- DELETE_LABEL_FUNCTION = $13;
-
- var
- xfcb : X_FCB;
-
- Function SetLabel( LabelName : string ): integer;
- var
- Str : PChar;
- Buf : array[1..128] of char;
-
- begin
- Str := Addr(Buf);
- StrPCopy( Str, LabelName );
- SetLabel := _lcreat( Str, faVolumeID );
- end;
-
- Function GetLabel( Drive : string ) : string;
- var
- SearchRec : TSearchRec;
- begin
- Result := '';
- if( FindFirst( Drive + '*.*', faVolumeID, SearchRec ) = 0) then
- Result := SearchRec.Name;
- end;
-
- { Fills the Extended FCB for a find. }
- Procedure FillFCBForFind( Drive : shortint );
- var
- i : integer;
- begin
- { Signifies an extended File Control Block FCB }
- xfcb.extended := $FF;
-
- { Volume label attribute. }
- xfcb.attribute := $8;
-
- { Drive number. }
- xfcb.drive := drive;
-
- { ????????.??? - DOS style 8.3 filemask. }
- FillChar( xfcb.FileName, SizeOf( xfcb.FileName ), '?' );
- FillChar( xfcb.Extension, SizeOf( xfcb.Extension ), '?' );
-
- end;
-
-
- Function ClearLabel( Drive : string ): integer;
- var
- RetVal : Byte;
- LabelName : string;
- begin
- if( Length( Drive ) >= 1 ) then
- begin
- Drive := UpperCase(Drive);
- FillFCBForFind( Ord(Drive[1]) - 64 );
- end
- else
- FillFCBForFind( 0 );
-
- asm
- mov DX,offset xfcb
- mov AH,DELETE_LABEL_FUNCTION
- Call DOS3Call
- mov RetVal,AL
- end;
- Result := RetVal;
- end;
- end.
-