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 dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems with registry

Status
Not open for further replies.

snerting

Programmer
Oct 20, 2005
52
This is probably not an Access-specific problem, but it's VB6 implementation of advapi32.dll so here it goes:

I'm using a registry setting to control how the access app should read data. The registry setting is controlled by another application. However, at some random intervals, the data read from registry is bugus. It seems to be a collection of spaces and line breaks, while the string in registry really is something else. If I run regedit and just double click the setting in question (without chanting anything), access will read it fine again.

The code:

Dim lResult As Long
Dim lKeyValue As Long
Dim sValue As String
Dim lValueLength As Long
Dim lDataTypeValue As Long

sValue = Space$(2048)
lValueLength = Len(sValue)

lResult = RegOpenKey(dataset.HKEY_CURRENT_USER, "software\\Foo\\bar", lKeyValue)
lResult = RegQueryValueEx(lKeyValue, "foobar", 0&, lDataTypeValue, sValue, lValueLength)
sValue = Left$(sValue, lValueLength - 1)


Any ideas on why this is happening?
 
What are RegOpenKey, dataset and RegQueryValueEx ?
Seems you have issue with Unicode.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Private Const HKEY_CURRENT_USER = &H80000001

Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, ByVal lpData As String, lpcbData As Long) As Long

Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long


Should perhaps have included those in my first post. :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top