Get Drive Serial : Management « Windows System « VB.Net






Get Drive Serial

  
Public Class MainClass
    Public Shared Function GetDriveSerial(ByVal DriveLetter As String) As String
        Dim strSelectText As String = "Win32_logicaldisk='" & DriveLetter & "'"
        Dim objMO As New System.Management.ManagementObject(strSelectText)
        objMO.Get()
        Return CType(objMO.Properties("VolumeSerialNumber").Value, String)
    End Function
    Public Shared Sub Main
        System.Console.WriteLine(GetDriveSerial("C:"))
    End Sub
End Class

   
    
  








Related examples in the same category