Question

I am trying to read a value from HKEY_CURRENT_USER\Software\Classes on Windows 7 as a standard user, and although the key exists, I get an error. Both codes below don't success:

l = RegOpenKeyEx(HKEY_CURRENT_USER, L"Software\\Classes", 0, KEY_READ, &hKey);

// RegOpenKeyEx doesn't success either
l = RegOpenKey(HKEY_CURRENT_USER, L"Software\\Classes", &hKey);

This code is located in a dll called by an application doing many things (I don't know all that it does).

However, a simple app with just RegOpenKey on the same computer with the same account works perfectly...

Can anyone tell me what could cause the problem and the differences between the two? The test app is written in c++, while the dll is written in c.

EDIT: Problem solved, by just removing the "L" before L"Software\Classes"...

Was it helpful?

Solution 2

I solved the problem by passing "Software\Classes" instead of L"Software\Classes" to the function.

OTHER TIPS

Likely, the code is running as a different user or its current user isn't in synch with the cached registry key for the process. See RegOpenCurrentUser.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top