Does anyone knows why this code is not working?
VB Code:
  1. Public Class Form1
  2.  
  3.     Private 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
  4.  
  5.  
  6.     Public Function GetSerial(ByVal str As String) As Long
  7.         Dim Buf$, Name$, Flags&, Length&
  8.         Dim Serial As Long
  9.         GetVolumeInformation(str, Buf$, 255, Serial, Length, Flags, Name$, 255)
  10.         GetSerial = Serial
  11.     End Function
  12.  
  13.     Private Sub Form_Load()
  14.         Label1.Text = CStr(GetSerial("C:\"))
  15.         'This prints the hard drive serial number of C: here. No other drive Is needed
  16.     End Sub
  17.  
  18. End Class