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




Reply With Quote