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"...

Était-ce utile?

La solution 2

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

Autres conseils

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top