Re: registry code sample

Tech-Archive recommends: Fix windows errors by optimizing your registry



You don't seem to understand pointers. For Example:

LPSECURITY_ATTRIBUTES sa;
sa->nLength=sizeof(SECURITY_ATTRIBUTES);//0

sa->lpSecurityDescriptor=NULL;

sa->bInheritHandle=TRUE;//true

LPDWORD disp;

if(RegCreateKeyEx(ihkey[0],subkey,0,NULL,options,rsam,sa,iphkey[1],disp)!=ERROR_SUCCESS)_er=1;

Both sa and disp are uninitialized pointers. They will cause immediate access violations or worse.

sa contains garbage. Then you immediately attempt to reference a member of it.

disp contains garbage. Then you immediately pass it to RegCreateKeyEx.

A hint: Never declare an 'LP' variable. Instead declar the actual object:

SECURITY_ATTRIBUTES sa;
sa.nLength = sizeof(SECURITY_ATTRIBUTES);

To pass this to RegCreateKeyEx use &sa

Don't do any more C or C++ programming until you understand this issue !!


--
Scott McPhillips [VC++ MVP]