A pretty typical story, I think:
I downloaded someone else's code, hoping that with it I wouldn't have to deal with Windows API to query/write to Registry. Then I get some funny behavior and, not knowing even where to start, I come to Tek-Tips for some expert advice.
Well, the code is attached. The weird thing is that the key (a String) looks normal when I view it using regedit. But when I use RegQueryValueEx, I get a weird string returned to me. The value is the path of an Access database:
C:\Documents And Settings\AUser\My Documents\Database.MDB
What I get back is:
C:\Documents And Settings\AUser\My Documents\Database.MDB o c u m e n t s \ d a t a b a s e . m d b
Does anyone have *ANY* idea why this happens?
Thanks! -Brad
ps I only included a chunk of code here, because sBuffer is messd up as of the RegQueryValueEx function (the last line)...
I downloaded someone else's code, hoping that with it I wouldn't have to deal with Windows API to query/write to Registry. Then I get some funny behavior and, not knowing even where to start, I come to Tek-Tips for some expert advice.
Well, the code is attached. The weird thing is that the key (a String) looks normal when I view it using regedit. But when I use RegQueryValueEx, I get a weird string returned to me. The value is the path of an Access database:
C:\Documents And Settings\AUser\My Documents\Database.MDB
What I get back is:
C:\Documents And Settings\AUser\My Documents\Database.MDB o c u m e n t s \ d a t a b a s e . m d b
Does anyone have *ANY* idea why this happens?
Thanks! -Brad
Code:
Function GetStringValue(SubKey As String, Entry As String)
Call ParseKey(SubKey, MainKeyHandle)
If MainKeyHandle Then
rtn = RegOpenKeyEx(MainKeyHandle, SubKey, 0, KEY_READ, HKey) 'open the key
If rtn = ERROR_SUCCESS Then 'if the key could be opened then
sBuffer = Space(255) 'make a buffer
lBufferSize = Len(sBuffer)
rtn = RegQueryValueEx(HKey, Entry, 0, REG_SZ, sBuffer, lBufferSize)
'...
End Function