'Open
New Project. Add a module, add DriveListBox and Button on
the form. 'Write down this public declaration in module. Declare Function GetVolumeInformation Lib "kernel32" Alias "GetVolumeInformationA" (ByVal lpRootPathName As String, ByVal lpVolumeNameBuffer As String, ByVal nVolumeNameSize As Long, lpVolumeSerialNumber As Long, lpMaximumComponentLength As Long, lpFileSystemFlags As Long, ByVal lpFileSystemNameBuffer As String, ByVal nFileSystemNameSize As Long) As Long Public Function GetSerialNumber(mDrive As String) As Long Dim nomorseri As Long Dim temp1 As String Dim temp2 As String temp1 = String(255, Chr$(0)) temp2 = String(255, Chr$(0)) t& = GetVolumeInformation(mDrive, temp1, Len(temp1), nomorseri, 0, 0, temp2, Len(temp2)) GetSerialNumber = nomorseri End Function 'Write the codes below in the form Private Sub Command1_Click() Dim x As String Dim y As Long x = Left(Drive1.Drive, 2) & "\" y = GetSerialNumber(x) If Not y = 0 Then MsgBox "Serial Number Drive " & Left(Drive1.Drive, 1) & " adalah " & y, , "Result" Else MsgBox "No serial number found!", , "Warning" End If End Sub Private Sub Form_Load() Command1.Caption = "Get Serial Number" End Sub
|