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



The information in this article applies to:

  • Microsoft Visual FoxPro for Windows 3.0b
  • Microsoft Visual FoxPro for Windows 5.0
  • Microsoft Visual FoxPro for Windows 5.0a
  • Microsoft Visual FoxPro for Windows 6.0
  • Microsoft Visual FoxPro 8.0
  • Microsoft Visual FoxPro 9.0 Professional Edition
  • Microsoft Visual FoxPro for Windows 7.0

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.

Modification Type:MajorLast Reviewed:1/27/2005
Keywords:kbcode kbhowto KB193774 kbAudDeveloper