Есть такая программа:
- Код: Выделить всё
'Beispiel: VB .Net - WMI - Win32_PhysicalMedia - Laufwerksinformationen ermitteln - Seriennummer ermitteln
'
Option Explicit On
Option Strict On
Imports System.Management
Imports System.Text
Imports System.Environment
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles MyBase.Load
With Me
.CenterToScreen()
End With
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles Button1.Click
Dim arrProp(13) As String
arrProp(0) = "Caption"
arrProp(1) = "CreationClassName"
arrProp(2) = "Description"
arrProp(3) = "Manufacturer"
arrProp(4) = "MediaDescription"
arrProp(5) = "Model"
arrProp(6) = "Name"
arrProp(7) = "OtherIdentifyingInfo"
arrProp(8) = "PartNumber"
arrProp(9) = "SerialNumber"
arrProp(10) = "SKU"
arrProp(11) = "Status"
arrProp(12) = "Tag"
arrProp(13) = "Version"
Dim i As Integer
Dim Result As String
Me.TextBox1.Text = ""
For i = 0 To 13
Result = DiskPropety(arrProp(i))
If Result IsNot Nothing Then
Me.TextBox1.Text = Me.TextBox1.Text + arrProp(i) + " = " + Result + NewLine
Else
Me.TextBox1.Text = "Nothing"
End If
Next
End Sub
Private Shared ReadOnly Property DiskPropety(ByVal prop As String) As String
Get
Try
Dim moc As ManagementObjectCollection = InitManagement()
Dim mo As ManagementObject
If moc IsNot Nothing Then
For Each mo In moc
If mo.Properties(prop).Value.ToString() IsNot Nothing Then
Return mo.Properties(prop).Value.ToString()
End If
Next
Else
Return "Нет данных"
End If
Catch
Return "Нет данных"
End Try
Return "Нет данных"
End Get
End Property
Private Shared Function InitManagement() As ManagementObjectCollection
Try
Dim query As String = " Select * from Win32_PhysicalMedia"
Dim mos As ManagementObjectSearcher = New ManagementObjectSearcher(query)
Dim moc As ManagementObjectCollection = mos.Get()
Return moc
Catch
Return Nothing
End Try
Return Nothing
End Function
End Class
Но она выдает данные только по PHYSICALDRIVE0.
Да и то только Серийный номер.
Подскажите как можно получить данные по другим дискам