Contents
Volume Label Component

See Also 	Properties 	Methods 	Events

Unit

LBLDLG

Description

The LBLDLG unit enables you to ReadVolume , WriteVolume , and DeleteVolume  labels for hard disk and floppy disk drives.

For Help on Help, Press F1


See Also

TComponent


Properties

Volume


Volume

Unit

LBLDLG

Declaration

Property Volume : TCaption read FVolume write Fvolume;

Definition

The Volume property is currently used as a storage location for a string. None of the methods of the LabelDialog component interact expressly with this property. (In other words it is superfluous.)


LBLDLG
(LBLDLG) Source Code Listing

unit Lbldlg;

{ LBLDLG.PAS - Acts as a component interface for the underlying code. }

{ Copyright (c) 1996. All Rights Reserved. }

{ by Paul Kimmel and Software Conceptions, Inc }

interface

uses

  SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,

  Forms, Dialogs;

type

  TLabelDialog = class(TCommonDialog)

  private

    { Private declarations }

    FVolume : TCaption;

  protected

    { Protected declarations }

  public

    { Public declarations }

  published

    { Published declarations }

    property Volume : TCaption read FVolume write FVolume;

    constructor Create( AOwner : TComponent ); override;

    function ReadVolume( drive : string ) : string;

    function WriteVolume( vol : string ) : integer;

    function DeleteVolume( drive : string ): integer;

  end;

procedure Register;

implementation

Uses Dosutil;

procedure Register;

begin

  RegisterComponents('Custom Controls', [TLabelDialog]);

end;

constructor TLabelDialog.Create( AOwner : TComponent );

begin

     inherited Create( AOwner );

     FVolume := Volume;

end;

function TLabelDialog.ReadVolume( drive : string ) : string;

begin

     try

        ReadVolume := GetLabel( drive );

     except

           on EInOutError do MessageDlg( drive + 'Not Found',

                          mtError, [mbOk], 0 );

     end;

end;

function TLabelDialog.WriteVolume( vol : string ) : integer;

begin

     try

        WriteVolume := SetLabel( vol );

     except

           on EInOutError do MessageDlg( 'Error Writing Label',

                          mtError, [mbOk], 0 );

     end;

end;

function TLabelDialog.DeleteVolume( drive : string ): integer;

begin

     try

        DeleteVolume := ClearLabel( drive );

     except

           on EInOutError do MessageDlg( 'Error Deleting Volume in drive ' +

                          drive, mtError, [mbOk], 0);

     end;

end;

end.


ReadVolume

Example

Unit

LBLDLG

Declaration

Function ReadVolume( drive : string ) : string;

Definition

Given a Pascal string containing a drive letter, this function returns the volume label of that drive.


WriteVolume

Example

Unit

LBLDLG

Declaration

Function WriteVolume( vol : string ) : integer;

Definition

Writes the volume label specified by by the string argument vol. You should delete the volume  label first with a call to DeleteVolume .

You will need to specify the drive letter (e.g. C:\TEST) when labeling the drive.


DeleteVolume

Example

Unit

LBLDLG

Declaration

Function DeleteVolume( drive : string ): integer;

Definition

Given a drive path as a string (e.g. A:\) this function erases the current volume label.


Methods

DeleteVolume

ReadVolume

WriteVolume


Events

None defined.


Example

Edit1.Text := LabelDialog1.ReadVolume( C:\ );


Example

DeleteVolume(C:\ );

{ Returns HFILE_ERROR if failed, otherwise returns a valid file handle. Disgard! }

if( LabelDialog1.WriteVolume( C:\TEST) <> HFILE_ERROR) then