Here's a quick demo. Paste this into a form with a command button on
it. It will print the serial number (and some other info) on the form.
You can change the drive letter to the appropriate one for your needs.
This also works on floppies CD-Roms.
-Dave
Option Explicit
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
Private Sub Command1_Click()
Dim SerialNum As Long
Dim Temp1 As String
Dim Temp2 As String
Dim RetVal As Long
Temp1 = Space(256)
Temp2 = Space(256)
RetVal = GetVolumeInformation("c:\", Temp1, Len(Temp1), SerialNum, 0,
0, Temp2, Len(Temp2))
Print SerialNum & vbCrLf & Temp1 & vbCrLf & Temp2
End Sub
Quote:
> Can anyone please help.
> Is there a API call to read the serial number of the local Hard drive using
> VB.
> Thanks
> Mahindra Morar