Export (0) Print
Expand All

SetVolumeLabel function

Sets the label of a file system volume.

Syntax


BOOL WINAPI SetVolumeLabel(
  _In_opt_  LPCTSTR lpRootPathName,
  _In_opt_  LPCTSTR lpVolumeName
);

Parameters

lpRootPathName [in, optional]

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 [in, optional]

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.

TechnologySupported

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 only]

Minimum supported server

Windows Server 2003 [desktop apps only]

Header

WinBase.h (include Windows.h)

Library

Kernel32.lib

DLL

Kernel32.dll

Unicode and ANSI names

SetVolumeLabelW (Unicode) and SetVolumeLabelA (ANSI)

See also

GetVolumeInformation
Volume Management Functions

 

 

Community Additions

ADD
Show:
© 2014 Microsoft