Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert Windows registry key path to string?

The straight WIN32API program I'm writing (no MFC, no .NET) uses the registry. Should a registry error occur, I'd like to print the full path of the key that failed.

HKEY_CLASSES_ROOT, HKEY_CURRENT_CONFIG, HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE, and HKEY_USERS are HKEY (DWORD) values (0x8000000 for HKEY_CLASSES_ROOT), etc. The subkey is a LPCTSTR, as is the value name.

Is there a method to convert the HKEY, subkey and value name (including any redirection (http://msdn.microsoft.com/en-us/library/windows/desktop/ms724072(v=vs.85).aspx)) to a text string?

I realize I can build a table of the HKEY's myself, and they're unlikely to change, but that's a crass way to do it.

like image 985
jcwren Avatar asked May 12 '26 05:05

jcwren


1 Answers

No such API that I know of. The only registry functions that give you names are RegEnum... functions, which give you names relative to an open key.

There isn't much demand for the reverse direction (HKEY to name), so the registry is probably indexed only in the common direction (name to HKEY).

You will have to keep track of names yourself as you navigate the hierarchy.

like image 131
Adrian McCarthy Avatar answered May 14 '26 15:05

Adrian McCarthy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!