devxlogo

GetDriveSerialNumber – Retrieving the serial number of the specified drive

GetDriveSerialNumber – Retrieving the serial number of the specified drive

' Retrieve the serial number of the specified drive' Note: requires a reference to the System.Management assembly' Example: MessageBox.Show(GetDriveSerialNumber("D"c))Function GetDriveSerialNumber(ByVal driveLetter As Char) As String    Dim driveFilter As String = "Win32_LogicalDisk=""" & driveLetter.ToString & _        ":"""    Dim drive As New System.Management.ManagementObject(driveFilter)    Return drive("VolumeSerialNumber")End Function

devx-admin

Share the Post: