set vfat label
To set the VFAT label in Delphi, you can use the SetVolumeLabel
function from the SysUtils
unit. Here is an example of how to do it:
uses
SysUtils;
function SetVFATLabel(const Drive: string; const LabelName: string): Boolean;
begin
Result := SetVolumeLabel(PChar(Drive), PChar(LabelName));
end;
In the above code, the SetVFATLabel
function takes two parameters: Drive
and LabelName
. The Drive
parameter specifies the drive letter or UNC path of the volume for which you want to set the label. The LabelName
parameter is the new label that you want to set.
The SetVolumeLabel
function sets the label of the specified volume. It returns True
if the label is set successfully, and False
otherwise.
To use the SetVFATLabel
function, you can call it like this:
if SetVFATLabel('C:\', 'NewLabel') then
ShowMessage('Label set successfully')
else
ShowMessage('Failed to set label');
In the above example, we are setting the label of the C drive to "NewLabel". If the label is set successfully, a message box with the text "Label set successfully" will be displayed. If setting the label fails, a message box with the text "Failed to set label" will be displayed.