我有一个HID设备,我需要在VB.NET中以编程方式禁用。我下载了WMICodeCreator,并使用它来生成ID我的设备的代码,但代码创建者不允许我访问任何禁用设备的方法(只查询它的状态)。
如何禁用该设备?
Imports System
Imports System.Management
Imports System.Windows.Forms
Namespace WMISample
Public Class MyWMIQuery
Public Overloads Shared Function Main() As Integer
Try
Dim searcher As New ManagementObjectSearcher( _
"root\CIMV2", _
"SELECT * FROM Win32_USBDevice WHERE DeviceID = 'USB\\VID_0596&PID_0586\\1B0033000251343439343037'")
For Each queryObj As ManagementObject in searcher.Get()
Console.WriteLine("-----------------------------------")
Console.WriteLine("Win32_USBDevice instance")
Console.WriteLine("-----------------------------------")
Console.WriteLine("DeviceID: {0}", queryObj("DeviceID"))
Next
Catch err As ManagementException
MessageBox.Show("An error occurred while querying for WMI data: " & err.Message)
End Try
End Function
End Class
End Namespace