-
Notifications
You must be signed in to change notification settings - Fork 0
/
modMachine.bas
32 lines (23 loc) · 938 Bytes
/
modMachine.bas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Attribute VB_Name = "modMachine"
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
'Clean up
Set Drv = Nothing
Set fso = Nothing
GetDriveSerialNumber = DriveSerial
End Function