我正在使用vb.net代码来尝试获取网络上任何计算机的显示器序列号。该代码适用于本地计算机,但我得到0远程计算机的结果。但是,使用相同的代码逻辑,我可以在远程计算机上获得其他值,例如ManufacturerName。我运行了一个WMI代码创建器,因为远程计算机的结果也是0。使用vbscript我可以得到正确的序列号,所以我知道vb代码的结果是错误的。我将不胜感激任何帮助。
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim objWMIService, colItems As Object
Dim strComputer As String, serialNum As String, instanceName As String
strComputer = "TDS57771-CCU"
objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\wmi")
colItems = objWMIService.ExecQuery("SELECT * FROM WMIMonitorID")
For Each objItems In colItems
serialNum = ""
If objItems.SerialNumberID Is Nothing Then
MsgBox("XXX")
Else
'arrSerialNumberID = objItems.SerialNumberID()
For Each arrValue As UInt16 In objItems.SerialNumberID
serialNum = serialNum & Chr(arrValue)
Next
End If
MsgBox(serialNum)
Next
End Sub