c++ - RegOpenKeyEx fails on HKEY_LOCAL_MACHINE -
Hi, I'm trying to read a registry value that I'm using Firefox This
is stored under HKEY_LOCAL_MACHINE \ SOFTWARE \ Mozilla \ Mozilla Firefox 3.0.10 \ bin (version number can be found elsewhere )
But I can not do anything under ERROR_SUCCESS to get RegOpenKeyEx to get back>
HKEY_LOCAL_MACHINE If this test fails:
if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, text ("\\ software"), 0, KEY_QUERY_VALUE, & amp; keyHandle) == ERROR_SUCCESS) While successful in this trial:
if (RegOpenKeyEx (HKEY_CLASSES_ROOT, text ("\\ shell"), 0, KEY_QUERY_VALUE, & amp; keyHandle == ERROR_SUCCESS)
The following code has failed with the error code 161 on my code, which means "bad way" (see this in winerror.h see):
long en = RegOpenKeyEx (HKEY_LOCAL_MACHINE, text ("software"), 0, KEY_QUERY_VALUE, & amp; H); I then changed the call to RegOpenKeyEx to use "software" (no leading slash note) and it worked:
#include & Lt; Windows.h & gt; # Include & lt; Iostream & gt; using namespace std; Int main () {HKEY hk; // Notice that this is software \\ software instead: Long N = RegOpenKeyEx (HKEY_LOCAL_MACHINE, text ("software"), 0, KEY_QUERY_VALUE, & amp; nbsp;); If (n == ERROR_SUCCESS) {cout & lt; & Lt; "OK" & lt; & Lt; Endl; } And {cout & lt; & Lt; "Failed with value" & lt; & Lt; N & lt; & Lt; Endl; }}
Comments
Post a Comment