The registry functions are returning "not found" on keys that certainly exist. I've got the right charset and using double backslashes, so that's not the problem.
Here is the output from exporting the key:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Netmon3]
"NetmonVersion"="3.4.2350.0"
"NPLVersion"="03.02"
"InstallDir"="C:\\prog\\netmon3\\"
"NetmonEdition"="Capture and Parser Engine"
Here is the function call:
x = RegOpenKeyExA(
HKEY_LOCAL_MACHINE,
"SOFTWARE\\Microsoft\\Netmon3",
0,
KEY_READ, &hKey);
The returned value x is 2, meaning ERROR_FILE_NOT_FOUND
. Using simply "SOFTWARE\\Microsoft
" as the string works fine, though.
Calling RegGetValue() has the same problem:
x = RegGetValueA(
HKEY_LOCAL_MACHINE,
"SOFTWARE\\Microsoft\\Netmon3",
"InstallDir",
RRF_RT_ANY,
NULL,
(PVOID)install_directory,
&BufferSize
);
Again, I'm getting 2 as the result, meaning not found.
I checked permissions on it, and all "Users" have "Read" permissions on it.
Whatever I'm missing, it's got to see be something obvious, but racking my brains, I can't see it.
--
Marsh Ray has the answer below: I was compiling 32-bit on a 64-bit system, and the Netmon3 install was 64-bit. Changing the build settings to 64-bit fixed the problem.
Perhaps you are running as a 32-bit process on a 64-bit Windows OS?
You can also use the 32-bit code, but then you have to specify an additional flag:
REGSAM flag = KEY_QUERY_VALUE|KEY_ENUMERATE_SUB_KEYS;
if(isWin64Bit()) flag |= KEY_WOW64_64KEY;
else flag |= KEY_WOW64_32KEY;
LONG err = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, SOME_REGKEY, 0, flag, &hKey);
The isWin64Bit method's implementation can be found here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With