Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

reqqueryvalueex returns nothing

Status
Not open for further replies.

compdrmt

Programmer
Sep 22, 2002
60
0
0
US
I am completly stumped

Any one explain why this does not work

This function

Public Function QueryKey(hKey As Long, subkey As String, keyname As String) As String

Dim lhandle As Long
Dim lpType As String
Dim rc As Long
lpType = String(1024, 0)

If Not RegOpenKeyEx(hKey, subkey, 0, KEY_ALL_ACCESS, lhandle) Then

If Not RegQueryValueEx(lhandle, keyname, 0, REG_SZ, lpType, 1024) Then

QueryKey = Left$(lpType, InStr(1, lpType, "0") - 1)
Else
QueryKey = ""
End If
Else
QueryKey = ""
End If

If lhandle <> 0 Then RegCloseKey lhandle

End Function


is called as follows

ret = QueryKey(HKEY_CURRENT_USER, "Software\company\product", "keydesired")

I have checked and the relevant values exist in the registry. The open key portion sees to go without a hitch



Debugging is the process of removing bugs. Programming is the process of putting them in
 
Put a stop in your code at this line

QueryKey = Left$(lpType, InStr(1, lpType, "0") - 1)

Run the code, and when it stops at this line, put

?Left$(lpType, InStr(1, lpType, "0") - 1)

in your immediate window and press enter to see what the value is

Transcend
[gorgeous]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top