好吧,我试图拉一个注册表项,它不会工作,每次我尝试它拉空值。我尝试以管理员身份运行单个exe文件以仔细检查权限。我创建了一个执行相同功能的批处理文件,并且它工作正常,并且我也使用了相同的方法来在我的脚本的其他部分提取注册表值,并且似乎无法找到问题。该程序运行良好,并显示0错误。VB2010当我试图拉注册表项时出现空白
源代码:
' Check Auto Update settings
Dim AUOptions_Value = My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update", "AUOptions", Nothing)
Dim AUOptions_level
If AUOptions_Value = 4 Then
AUOptions_level = "Auto Update Options set to: Install Updates Automatically."
Display_AUOptions.ForeColor = Color.Green
ElseIf AUOptions_Value = 3 Then
AUOptions_level = "Download Updates but let me choose whether to install them."
Display_AUOptions.ForeColor = Color.Blue
ElseIf AUOptions_Value = 2 Then
AUOptions_level = "Check for updates but let me choose whether to download them and install them."
Display_AUOptions.ForeColor = Color.Blue
ElseIf AUOptions_Value = 1 Then
AUOptions_level = "Never check for updates."
Display_AUOptions.ForeColor = Color.Red
Else
AUOptions_level = "Unable to detect settings"
Display_AUOptions.ForeColor = Color.Red
End If
Display_AUOptions.Text = AUOptions_level
End Sub
注册表项:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update]
"AUOptions"=dword:00000004
你作为构建32位在64位操作系统上的应用程序?如果是这样的话,你实际上会从'HKEY_LOCAL_MACHINE \ SOFTWARE \ Wow6432Node \ Microsoft \ Wind ...'中读取这个密钥并检查 –