好吧,我試圖拉一個註冊表項,它不會工作,每次我嘗試它拉空值。我嘗試以管理員身份運行單個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 ...'中讀取這個密鑰並檢查 –