PDA

Click to See Complete Forum and Search --> : RegSetValueEx function


abhid
Jan 16th, 2002, 03:00 AM
Hi all
I want to create string keys and save a string in that key. For this
purpose i am using RegSetValueEx function. But it saves some
junk characters in registry.
I am using it like

strDatabasePath = "d:\Project\FileName"
lngcbdata = lngcbData = Len(strDatabasePath)
' Result is the key identifier
RegSetValueEx Result, "File Path", 0, REG_SZ, strDatabasePath, lngcbData

am i making a mistake?

Si_the_geek
Jan 16th, 2002, 03:59 AM
yep, you need to change it slightly - add a chr(0) to the end (it's how C expects it, and API functions like this are C based).

lngcbdata = Len(strDatabasePath) + 1
' Result is the key identifier
RegSetValueEx Result, "File Path", 0&, REG_SZ, strDatabasePath & chr(0), lngcbData

abhid
Jan 16th, 2002, 04:28 AM
thanks si_the_geek but still the same problem.

Si_the_geek
Jan 16th, 2002, 04:31 AM
Have you set the variable REG_SZ?

It should be:
REG_SZ = &O1

abhid
Jan 16th, 2002, 04:39 AM
yes I have.
Even i am assigning the buffer size of string also.

abhid
Jan 16th, 2002, 04:54 AM
Its solved...........
it should be

RegSetValueEx Result, "Database Path", 0&, REG_SZ, ByVal strDatabasePath, lngcbData

that byval was causing all the problem!