FKart PrmotionalBanners

GetDriveSerialNumber/MotherBoardserial No

 Public Function MBSerialNumber() As String
'RETRIEVES SERIAL NUMBER OF MOTHERBOARD
'IF THERE IS MORE THAN ONE MOTHERBOARD, THE SERIAL
'NUMBERS WILL BE DELIMITED BY COMMAS

'YOU MUST HAVE WMI INSTALLED AND A REFERENCE TO
'Microsoft WMI Scripting Library IS REQUIRED

Dim objs As Object
Dim obj As Object
Dim WMI As Object
Dim sAns As String

Set WMI = GetObject("WinMgmts:")
Set objs = WMI.InstancesOf("Win32_BaseBoard")
For Each obj In objs
sAns = sAns & obj.SerialNumber
If sAns < objs.Count Then sAns = sAns & ","
Next
MBSerialNumber = sAns
End Function
'------------------------------------------------------------------------------

Public Function GetDriveSerialNumber(Optional ByVal DriveLetter As String) As Long

Dim fso As Object, Drv As Object
Dim DriveSerial As String
'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

Comments

Popular Posts