读取注册表的问题
我现在已经成功写了注册表,可是读取不行,读的值老是空串。
我的程序如下:
Public Function g_cmdQueryValue() As Integer
Dim hKeyMyKey As Long
Dim lResult As Long
Dim msg, response
'打开注册表项
lResult = RegOpenKeyEx(HKEY_CURRENT_USER, "Software\mykey", 0, KEY_ALL_ACCESS, hKeyMyKey)
If lResult = ERROR_SUCCESS Then
g_cmdQueryValue = RegQueryValueEx(hKeyMyKey, "TestValue", 0, REG_SZ, szValue, Len(szValue))
'关闭注册表项
RegCloseKey (hKeyMyKey)
Else
g_cmdQueryValue = 1
End If
End Function
请高手指教,谢谢!