我正在开发一个用于在连接时检测和阻止可移动USB设备的项目。 我只需要扫描连接的USB设备的代码。
答案 0 :(得分:1)
答案 1 :(得分:0)
Private Sub cmdOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdOK.Click
Dim regKey As RegistryKey
Dim ver As Decimal
'opens the path USBSTOR from regedit
If rbtnDisable.Checked Then
If MsgBox("All USB Ports Will Be Disabled Except The Presently Connected Ports (Ex.,USB Mouse,Printer etc !) ", MsgBoxStyle.OkCancel, "ARE YOU SURE ?!") = MsgBoxResult.Ok Then
regKey = Registry.LocalMachine.OpenSubKey("SYSTEM\CurrentControlSet\Services\USBSTOR", True)
regKey.SetValue("Start", 4) ' 4(To disable the ports)
End If
Else
regKey = Registry.LocalMachine.OpenSubKey("SYSTEM\CurrentControlSet\Services\USBSTOR", True)
regKey.SetValue("Start", 3) ' 3(To enable the ports)
MsgBox("Ports Are Enabled !", MsgBoxStyle.OkOnly)
End If
End Sub
我将此代码用于block/enable USB Port(s)