错误访问注册表项' HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Ser

时间:2016-09-30 14:53:48

标签: vb.net visual-studio-2010 registry

尝试禁用或启用端口时出现此问题。当我使用我朋友的笔记本电脑时,它运行良好,但当我尝试使用我的笔记本电脑时,它会出现此错误。为什么会发生这种情况以及如何解决?谢谢^^

Private Sub DisableBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DisableBtn.Click
        Microsoft.Win32.Registry.SetValue("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\USBSTOR", "Start", 4, Microsoft.Win32.RegistryValueKind.DWord) 'this line gives error
        MessageBox.Show("Port are disable", "USB Disable", MessageBoxButtons.OK, MessageBoxIcon.Information)
        Me.Hide()
        Login.Show()
    End Sub
    Private Sub EnableBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EnableBtn.Click
        Microsoft.Win32.Registry.SetValue("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\USBSTOR", "Start", 3, Microsoft.Win32.RegistryValueKind.DWord) 'this line gives error
        MessageBox.Show("Port are enable", "USB Enable", MessageBoxButtons.OK, MessageBoxIcon.Information)
        Me.Hide()
        Login.Show()
    End Sub

0 个答案:

没有答案