Is there any way to enumerate the top level keys in the registry?

SunnyD

Belgian Waffler
Jan 2, 2001
32,675
146
106
www.neftastic.com
All I can find is RegOpenKey, which takes either a user defined key or one of the predefined root keys. What I'm looking for is to actually enumerate which top level keys are loaded (since it differs between Windows versions).

Ideas?
 

DaveSimmons

Elite Member
Aug 12, 2001
40,730
670
126
Getting the OS version first then adjusting your code accordingly will work of course, but I realize you're looking for something cleaner. I've never needed to do this so I'm no help :) .

You may want to have OS-specific code anyway since in Vista for example I don't think a normal exe (without a manifest resource for admin access) can get write access to HKCR, just HKCU.
 

SunnyD

Belgian Waffler
Jan 2, 2001
32,675
146
106
www.neftastic.com
Originally posted by: DaveSimmons
Getting the OS version first then adjusting your code accordingly will work of course, but I realize you're looking for something cleaner. I've never needed to do this so I'm no help :) .

You may want to have OS-specific code anyway since in Vista for example I don't think a normal exe (without a manifest resource for admin access) can get write access to HKCR, just HKCU.

I don't need write access... just KEY_READ will suffice. I've pretty much done what you said so far (though just the base keys that are common on all systems). I suppose that's what I'll have to live with... keeps me in a job when a new version of Windows comes out I suppose.
 

SunnyD

Belgian Waffler
Jan 2, 2001
32,675
146
106
www.neftastic.com
Originally posted by: xtknight
What you're looking for is a way to enumerate registry "hives". I don't have an answer but this might help point you in the right direction. Maybe you could check if the hives' files exist?

http://www.governmentsecurity....NTRegistryTutorial.php

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\hivelist

This seems to list some hives.

WOW!

Perfect! I'll have to do a little research to see if it actually covers the currently loaded registry hives or whatnot, but that looks to be pretty much exactly what I want! Thanks!