逗号,')'或预期的有效表达式延续 - 注册表错误

时间:2014-05-15 16:08:03

标签: vb.net windows registry expression comma

我正在为企业和公司公司创建一个初创的二级登录屏幕。但是,我试图通过使用注册表DWORD值禁用任务管理器。当我添加代码时,它会出现错误"逗号,')'或预期的有效表达式延续"。我该怎么办?

    Imports Microsoft.Win32

Public Class Form1
    Dim regKey As RegistryKey
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        regKey = Registry.CurrentUser.OpenSubKey("regKey.SetValue("***HKEY***\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System")
        regKey.SetValue("DisableTskMgr", 1, RegistryValueKind.DWord)

    End Sub
    Private Sub frmMyform_FormClosing(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        Dim Cancel As Boolean = eventArgs.Cancel
        Dim UnloadMode As System.Windows.Forms.CloseReason = eventArgs.CloseReason
        If UnloadMode = CloseReason.UserClosing Then

            Cancel = True
        End If
    End Sub

End Class

我的问题在于上面的HKEY系统。提前致谢!

1 个答案:

答案 0 :(得分:0)

我认为这应该是这样的:

regKey = Registry.CurrentUser.OpenSubKey( "regKey.SetValue(""***HKEY***\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System"")" )

请参阅Escape double quote in VB string

MsgBox("""") ' Prints a single "