This question is related to Windows registry key opening.
Please refer to the following two lines of VC++ code
printf ("queryRegistry Setting:%s - %s - %s\n", subElement,
variableName, variableType);
[color=blue]
> output: queryRegistrySe tting: Software\\xx\\x x\\xx\\xx\\xx - Args -[/color]
EXPAND_STRING
long result = RegOpenKeyEx (HKEY_LOCAL_MAC HINE, subElement, 0,
KEY_ALL_ACCESS, &key);
[color=blue]
> output: fails with return value of 87[/color]
[color=blue]
>From winerror.h: #define ERROR_INVALID_P ARAMETER 87L // dderror[/color]
But,
long result = RegOpenKeyEx (HKEY_LOCAL_MAC HINE,
"Software\\xx\\ xx\\xx\\xx\\xx" , 0, KEY_ALL_ACCESS, &key);
succeeds without any error. As you can see, in the second case, I have
replaced the variable subElement, with actual value.
Once it succeeds with the above change, even if I use the variable
subElement, i.e.
long result = RegOpenKeyEx (HKEY_LOCAL_MAC HINE, subElement, 0,
KEY_ALL_ACCESS, &key);
succeeds without any error, till I logout and login or reboot the
system.
Alternate way of executing RegOpenKeyEx without error:
----------------------------------------------------------------------------------
Instead of replacing subElement with actual value, if I do,
a. Start->Run->regedit
b. this opens the registry editor.
c. without doing any change, I just close the registry editor.
After this,
long result = RegOpenKeyEx (HKEY_LOCAL_MAC HINE, subElement, 0,
KEY_ALL_ACCESS, &key); succeeds without any error.
Could someone, explain, if they have faced similar issue and if so, how
this is solved, please ?
Thanks in advance for your help.
Please refer to the following two lines of VC++ code
printf ("queryRegistry Setting:%s - %s - %s\n", subElement,
variableName, variableType);
[color=blue]
> output: queryRegistrySe tting: Software\\xx\\x x\\xx\\xx\\xx - Args -[/color]
EXPAND_STRING
long result = RegOpenKeyEx (HKEY_LOCAL_MAC HINE, subElement, 0,
KEY_ALL_ACCESS, &key);
[color=blue]
> output: fails with return value of 87[/color]
[color=blue]
>From winerror.h: #define ERROR_INVALID_P ARAMETER 87L // dderror[/color]
But,
long result = RegOpenKeyEx (HKEY_LOCAL_MAC HINE,
"Software\\xx\\ xx\\xx\\xx\\xx" , 0, KEY_ALL_ACCESS, &key);
succeeds without any error. As you can see, in the second case, I have
replaced the variable subElement, with actual value.
Once it succeeds with the above change, even if I use the variable
subElement, i.e.
long result = RegOpenKeyEx (HKEY_LOCAL_MAC HINE, subElement, 0,
KEY_ALL_ACCESS, &key);
succeeds without any error, till I logout and login or reboot the
system.
Alternate way of executing RegOpenKeyEx without error:
----------------------------------------------------------------------------------
Instead of replacing subElement with actual value, if I do,
a. Start->Run->regedit
b. this opens the registry editor.
c. without doing any change, I just close the registry editor.
After this,
long result = RegOpenKeyEx (HKEY_LOCAL_MAC HINE, subElement, 0,
KEY_ALL_ACCESS, &key); succeeds without any error.
Could someone, explain, if they have faced similar issue and if so, how
this is solved, please ?
Thanks in advance for your help.
Comment