'Note: This code requires a referecne to the Microsoft Scripting Runtime library (SCRRUN.DLL)
Private Sub Form_Load()
'Show drive serial number for the current drive
MsgBox " Drive serial number for " & Left(App.Path, 1) & ": " & GetDriveSerialNumber
End
End Sub
Public Function GetDriveSerialNumber(Optional ByVal DriveLetter As String) As Long
Dim fso As Object, Drv As Object
'Create a FileSystemObject object
Set fso = CreateObject("Scripting.FileSystemObject")
'Assign the current drive letter if not specified
If DriveLetter <> "" Then
Set Drv = fso.GetDrive(DriveLetter)
Else
Set Drv = fso.GetDrive(fso.GetDriveName(App.Path))
End If
With Drv
If .IsReady Then
DriveSerial = Abs(.SerialNumber)
Else '"Drive Not Ready!"
DriveSerial = -1
End If
End With
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum