SetVolumeLabel Function

Declare Function SetVolumeLabel Lib "kernel32.dll" Alias "SetVolumeLabelA" (ByVal lpRootPathName As String, ByVal lpVolumeName As String) As Long

Platforms

Description & Usage

SetVolumeLabel sets the label of a file system volume. The new volume label must comply with length constaints and cannot contain any invalid characters.

Return Value

If an error occured, the function returns 0 (use GetLastError to get the error code). If successful, the function returns a non-zero value.

Visual Basic-Specific Issues

None.

Parameters

lpRootPathName
The path of the root directory of the drive to set the file system volume label of. This path must include the trailing backslash. For example, the C: drive would be "C:\".
lpVolumeName
The new name to assign to the volume.

Example

' This code is licensed according to the terms and conditions listed here.

' Declarations and such needed for the example:
' (Copy these to the (declarations) section of a module.)
Public Declare Function SetVolumeLabel Lib "kernel32.dll" Alias "SetVolumeLabelA" _
	(ByVal lpRootPathName As String, ByVal lpVolumeName As String) As Long

' Set the file system volume label of the C: drive to "MYDRIVE".
Dim retval As Long  ' return value

' Set the new volume label.
retval = SetVolumeLabel("C:\", "MYDRIVE")

See Also

GetVolumeInformation

Category

File System

Back to the Function list.
Back to the Reference section.


Last Modified: April 16, 2000
This page is copyright © 2000 Paul Kuliniewicz. Copyright Information Revised October 29, 2000
Go back to the Windows API Guide home page.
E-mail: vbapi@vbapi.com Send Encrypted E-Mail
This page is at http://www.vbapi.com/ref/s/setvolumelabel.html