SetVolumeLabelA function

Sets the label of a file system volume.

Syntax

BOOL SetVolumeLabelA(
  LPCSTR lpRootPathName,
  LPCSTR lpVolumeName
);

Parameters

lpRootPathName

A pointer to a string that contains the volume's drive letter (for example, X:) or the path of a mounted folder that is associated with the volume (for example, Y:\MountX). The string must end with a trailing backslash (''). If this parameter is NULL, the root of the current directory is used.

lpVolumeName

A pointer to a string that contains the new label for the volume. If this parameter is NULL, the function deletes any existing label from the specified volume and does not assign a new label.

Return Value

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

The maximum volume label length is 32 characters.

FAT filesystems:  The maximum volume label length is 11 characters.

A label is a user-friendly name that a user assigns to a volume to make it easier to recognize. A volume can have a label, a drive letter, both, or neither. For more information, see Naming a Volume.

In Windows 8 and Windows Server 2012, this function is supported by the following technologies.

Technology Supported
Server Message Block (SMB) 3.0 protocol No
SMB 3.0 Transparent Failover (TFO) No
SMB 3.0 with Scale-out File Shares (SO) No
Cluster Shared Volume File System (CsvFS) Yes
Resilient File System (ReFS) Yes
 

SMB does not support volume management functions.

Requirements

   
Minimum supported client Windows XP [desktop apps | UWP apps]
Minimum supported server Windows Server 2003 [desktop apps | UWP apps]
Target Platform Windows
Header winbase.h (include Windows.h)
Library Kernel32.lib
DLL Kernel32.dll

See Also

GetVolumeInformation

Volume Management Functions