Setting Large (Binary) values in Registry 
Author Message
 Setting Large (Binary) values in Registry

As a matter of fact , someone else posted this message last year.. but no
solution was proposed by anyone to the problem. I am having the same
problem. Any help in this regard will be appreciated.
Thanks

I am using the RegSetValueEx function.The code looked like:

LPTSTR regData;regData =
"\x01\x02\x03\x04\x05\x06\x07";RegSetValueEx(hOrigKey, "center", 0,
REG_BINARY, (CONST BYTE*)regData, sizeof(regData));

Please note that only \x01 up through \x04 would enter into registry, \x05
and above all the way to \x56 would not be entered into the registry. Why I
cannot figure out yet...



Sun, 20 Oct 2002 03:00:00 GMT  
 Setting Large (Binary) values in Registry
The problem is "sizeof(regData)". regData is a pointer, so the size of the
pointer itself is just 4 bytes. What you really need is the size of the
buffer that regData is pointing to. For this particular code sample you
could use "lstrlen(regData)" (or "lstrlen(regData) * sizeof(TCHAR)", if
you're ever going to do a Unicode compile).

--Carter



Quote:
> As a matter of fact , someone else posted this message last year.. but no
> solution was proposed by anyone to the problem. I am having the same
> problem. Any help in this regard will be appreciated.
> Thanks

> I am using the RegSetValueEx function.The code looked like:

> LPTSTR regData;regData =
> "\x01\x02\x03\x04\x05\x06\x07";RegSetValueEx(hOrigKey, "center", 0,
> REG_BINARY, (CONST BYTE*)regData, sizeof(regData));

> Please note that only \x01 up through \x04 would enter into registry, \x05
> and above all the way to \x56 would not be entered into the registry. Why
I
> cannot figure out yet...



Sun, 20 Oct 2002 03:00:00 GMT  
 Setting Large (Binary) values in Registry
You're passing RegSetValueEx() the sizeof the POINTER to the data, not
the size of the data.

Also, you should NOT be using TCHAR/LPTSTR here. TCHAR's change size
depending on whether its a unicode build of the app, so a unicode
build won't read settings made by a non-unicode build correctly. Use
LPSTR or LPWSTR.

On Wed, 3 May 2000 18:46:32 -0400, "a t i f   s a l a m"

Quote:

>As a matter of fact , someone else posted this message last year.. but no
>solution was proposed by anyone to the problem. I am having the same
>problem. Any help in this regard will be appreciated.
>Thanks

>I am using the RegSetValueEx function.The code looked like:

>LPTSTR regData;regData =
>"\x01\x02\x03\x04\x05\x06\x07";RegSetValueEx(hOrigKey, "center", 0,
>REG_BINARY, (CONST BYTE*)regData, sizeof(regData));

>Please note that only \x01 up through \x04 would enter into registry, \x05
>and above all the way to \x56 would not be entered into the registry. Why I
>cannot figure out yet...

Don Grasberger
Apply Occam's razor to Bill's beard.

(remove --- from address to e-mail)



Mon, 21 Oct 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Setting large binary values in registry using RegSetValueEx

2. Registry & Binary Values

3. Getting Binary Registry Key Value

4. Reading binary registry value

5. Read a binary value from the registry

6. Registry & Binary Values

7. HELP: How to Query Binary registry values

8. HELP: How to Query Binary registry values

9. Writing Binary Values to Win95 Registry

10. Read/Set Binary Data in registry

11. Help Need setting Windows NT Registry Values

12. Install project, set registry value with install directory?

 

 
Powered by phpBB® Forum Software