Monday, March 22, 2010

VB6 Code - Mengganti Label Volume Sebuah Drive

Di bawah ini merupakan kode VB6 untuk mengganti label volume sebuah drive . Bagaimanakah implementasinya dalam pengkodean:
Option Explicit

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

Private Function SetLabel(RootName As String, NewLabel As String)
If RootName = "" Then
Exit Function
End If
Call SetVolumeLabel(RootName, NewLabel)
End Function
Contoh menggunakan fungsi mengganti label volume sebuah drive:
Private Sub Command1_Click()
Call SetLabel("D:\", "Drive D")
End Sub