Hard Drive Serial Number?
?I'm trying to retrieve the Hard Drive
?Serial Number from my VB application.
?
?I would like to know if anybody know how to do so.
?It would be great it I can get some source code if not all,
?and if it is possible not to jump to dos and would be able to
?access in both NT/9x.
The following code works fine for me:
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 Form_Load()
Dim nRet As Long
Dim VolName As String
Dim VolSN As Long
Dim sVolSN As String
Dim MaxCompLen As Long
Dim VolFlags As Long
Dim VolFileSys As String
VolName = Space$(256)
VolFileSys = Space$(256)
nRet = GetVolumeInformation("C:\", VolName, Len(VolName), VolSN, _
MaxCompLen, VolFlags, VolFileSys, Len(VolFileSys))
sVolSN = Hex(VolSN)
End Sub
Paul
~~~~