Re: registry code sample
- From: Vincent Fatica <vince@xxxxxxxxxxxxxxxxx>
- Date: 25 Jan 2009 14:51:32 -0500
On Sun, 25 Jan 2009 18:41:55 +0100, "Starglider 4 \(Marco Knoester\)" <x@xxxxxx>
wrote:
You don't seem to need two steps and can probably start with
DWORD dwDisp;
HKEY hKeyCompany;
if ( RegCreateKey(HKEY_CURRENT_USER, "Software\\company",
0, NULL, 0, KEY_ALL_ACCESS, NULL, &hKeyCompany, &dwDisp) ) ...
I used NULL for lpSecurityAttributes. do you really need to make the handle
inheritable?
LPDWORD disp;
if(RegCreateKeyEx(ihkey[0],subkey,0,NULL,options,rsam,sa,iphkey[1],disp)!=ERROR_SUCCESS)_er=1;
What does "disp" point to? (Answer: nothing) You've done that more than once.
And it will cause an error. Declaring a pointer does not automatically make it
point to anything. There's no real need for the pointer itself. Just use
"DWORD dwDisp" and specify its location (&dwDisp, as above).
***********************
const BYTE* data;
BYTE d=0;
Something is fishy here. You have **one** byte of data ...
data=&d;
DWORD size=sizeof(DWORD);
if(RegSetValueEx(ihkey[1],value_name,0,REG_DWORD,data,size)!=ERROR_SUCCESS)_er=1;
.... but you tell RSVEx() to read (from the location data) **four** bytes.
How about,
DWORD dwData = 0; // or whatever value you want in the registry
if(RegSetValueEx(hKeyCompany,"val1",0,REG_DWORD,&dwData,sizeof(DWORD)) ...
dwData = 0; // or whatever value you want in the registry
if(RegSetValueEx(hKeyCompany,"val2",0,REG_DWORD,&dwData,sizeof(DWORD)) ...
--
- Vince
.
- Follow-Ups:
- Re: registry code sample
- From: Starglider 4 \(Marco Knoester\)
- Re: registry code sample
- References:
- registry code sample
- From: Starglider 4 \(Marco Knoester\)
- Re: registry code sample
- From: Norman Bullen
- Re: registry code sample
- From: Starglider 4 \(Marco Knoester\)
- registry code sample
- Prev by Date: Re: registry code sample
- Next by Date: Re: registry code sample
- Previous by thread: Re: registry code sample
- Next by thread: Re: registry code sample
- Index(es):