|
-
August 24th, 1999, 11:45 AM
#1
problem with reading registry value in VB
i kept getting memory error ('mem could not be read') when i used the following to query a registry value:
----
r1 = RegOpenKeyEx( HKEY_CURRENT_USER, "RemoteAccess", 0, KEY_QUERY_VALUE, phkResult)
if r1= ERROR_SUCCESS then
l= 50
subkey = "myteststringval"
r2 = RegQueryValueEx( phkResult, subkey$, 0, REG_EXPAND_SZ, data, l )
'I got the above mem error when stepping over this statement and couldn't proceed
...
...
RegCloseKey(phkResult)
----
all consts and declares has been made.
can anyone give me a hint why the memory error always come up ? each time
i succeeded in opening the key but failed on the query...
thanks in advance to any help, will appreciate it.
Ying
-
August 26th, 1999, 07:40 AM
#2
Re: problem with reading registry value in VB
Hi Ying:
I read the windows registry with the next code and work fine... Perhaps you can try it.
Good luck, Bye
lResult = RegOpenKeyEx(HKEY_LOCAL_MACHINE, Clave, 0, KEY_READ, hKey)
If lResult = ERROR_SUCCESS then
Dim lType as Long
Dim lReturned as Long
lResult = RegQueryValueEx(hKey, "MyString", 0, lType, 0, lReturned)
Call RegCloseKey(hKey)
-
August 27th, 1999, 01:51 AM
#3
Re: problem with reading registry value in VB
Remove the $, and try!!, because the way VB interprets some of the 'old' basic syntax could be confusing!!.
...
subkey = "myteststringval"
' subkey$ = "myteststringval" ' have like this,if you want!!
' No $ in next line!
r2 = RegQueryValueEx( phkResult, subkey, 0, REG_EXPAND_SZ, data, l )
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|