RegOpenKeyEx在Windows 7上失败,87

时间:2014-07-21 09:58:00

标签: vb.net registry

我试图在Visual Basic 2005 Express中打开注册表项:

Private Const HKEY_CURRENT_USER = &H80000001
Private Const KEY_READ = &H20019    
Dim longResult as Long
Dim hKey as Long
longResult = RegOpenKeyEx(HKEY_CURRENT_USER, "Software\AppDataLow", 0&, KEY_READ, hKey)

但是我总是在longResult中得到错误87。 由于这是Windows 7 64位我也试过

KEY_READ Or &H100
KEY_READ Or &H200
KEY_READ Or &H300

但这些都不起作用,总是得到87返回值,意思是"无效参数"。 RegOpenKeyEx的声明是:

Private Declare Function RegOpenKeyEx Lib "advapi32.dll" _
    Alias "RegOpenKeyExA" ( _
    ByVal hKey As Long, _
    ByVal lpSubKey As String, _
    ByVal ulOptions As Long, _
    ByVal samDesired As Long, _
    ByVal phkResult As Long) As Long

提前致谢

1 个答案:

答案 0 :(得分:1)

首先,阅读所有this

然后,导入Microsoft.Win32并改为使用these方法。