Knowledge Base

How to programmatically change the volume label of a drive from Visual FoxPro

Article ID: 193774

Article Last Modified on 1/27/2005


APPLIES TO


This article was previously published under Q193774

SUMMARY

You can change the volume label of a drive programmatically by using the SetVolumeLabel() Windows API function.

MORE INFORMATION

The following example demonstrates the use of the SetVolumeLabel() API function to change the volume label of a floppy disk.

Sample code

   DECLARE INTEGER SetVolumeLabel IN Win32API STRING lcRootPath,;
      STRING lcVolumeLabel

   liRetVal = 0
   * Message box with OK/Cancel buttons
   liRetVal = MESSAGEBOX("Insert scratch floppy disk in drive A:",;
      1)

   * Handle non-OK selection from message box
   IF liRetVal # 1
      RETURN
   ENDIF

   lcVolumeLabel = "Test"
   = SetVolumeLabel ("A:\", lcVolumeLabel)
				
You can examine the drive label by right-clicking the drive in Windows Explorer and selecting Properties. The volume label is located near the top of the General tab on the Property page.

Additional query words: kbVFp600 kbAPI kbVFp500a kbVFp500 kbVFp300b

Keywords: kbhowto kbcode KB193774