如何使用vb.net阻止Windows中的USB端口

时间:2014-07-03 06:42:34

标签: c# vb.net

我是vb.net编程的新手,正在开发一个实验性应用程序来阻止USB个计算机中的windows端口,可以通过编辑regedit中的某些值来实现编程新我完全空白,任何帮助将非常感激

2 个答案:

答案 0 :(得分:1)

  • 首先导入以下内容
  

Imports Microsoft.Win32

  • 禁用/阻止

    的功能
    Private Sub functionToBlock()
        Dim regKey As RegistryKey
        regKey = Registry.LocalMachine.OpenSubKey("SYSTEM\CurrentControlSet\Services\USBSTOR", True)
        regKey.SetValue("Start", 4) //' 4(To disable the ports)
    End Sub
    
  • 启用/取消阻止功能

    Private Sub functionToUnblock()
       Dim regKey As RegistryKey
       regKey = Registry.LocalMachine.OpenSubKey("SYSTEM\CurrentControlSet\Services\USBSTOR", True)
       regKey.SetValue("Start", 3) //' 3(To enable the ports)
    End Sub
    

答案 1 :(得分:0)

下面的解决方案适用于32位窗口但不能正常工作64位...

//禁用USB存储......

Microsoft.Win32.Registry.SetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\USBSTOR", "Start", 4, Microsoft.Win32.RegistryValueKind.DWord);

//启用USB存储......

Microsoft.Win32.Registry.SetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\USBSTOR", "Start", 3, Microsoft.Win32.RegistryValueKind.DWord);