2
votes

MSDN says:

Class registration and file name extension information is stored under both the HKEY_LOCAL_MACHINE and HKEY_CURRENT_USER keys. The HKEY_LOCAL_MACHINE\Software\Classes key contains default settings that can apply to all users on the local computer. The HKEY_CURRENT_USER\Software\Classes key contains settings that apply only to the interactive user. The HKEY_CLASSES_ROOT key provides a view of the registry that merges the information from these two sources. HKEY_CLASSES_ROOT also provides this merged view for applications designed for previous versions of Windows.

Does that mean if I add a subkey to HKEY_LOCAL_MACHINE\Software\Classes (say a new file extension), the container of HKEY_CLASSES_ROOT will update automatically and accordingly?

If not, what should I do?

1
On a word, yes. It is handled automaticallyRemy Lebeau
Yes it will. HKEY_CLASSES_ROOT is a kind of alias (as is HKEY_CURRENT_USER).Paul Sanders
@Remy Lebeau, Paul Sanders, Thanks, I see.foo
HKCR is messy, designed to be the compatibility view for programs that started life in the 16-bit version of Windows. Always avoid if you can help it.Hans Passant
HKCR was changed to a merged view in NT 5. This is implemented at runtime by the Windows registry API. Also, the current-user software classes is a separate hive ("%LocalAppData%\Microsoft\Windows\UsrClass.dat"), which intentionally does not roam with the user profile. A user's "Software\Classes" key is a symlink to this hive, which is loaded under HKU as "<SID>_Classes". Also, for the handle aliases (not symlinks), HKLM is for "\Registry\Machine", HKU is for "\Registy\User", and HKCU is for "\Registry\User\<SID>". Internally these handle aliases get mapped to real Key handles on first use.Eryk Sun

1 Answers

4
votes

HKEY_CLASSES_ROOT is not a real physical hive (it stores no data), it is just a merged view of HKEY_CURRENT_USER\Software\Classes and HKEY_LOCAL_MACHINE\Software\Classes. Updates to the underlying keys are instantly visible in HKEY_CLASSES_ROOT.

Values in HKEY_CURRENT_USER override values in HKEY_LOCAL_MACHINE because when accessing HKEY_CLASSES_ROOT, the Registry internals tries to read from HKEY_CURRENT_USER first.

Additionally, HKEY_CURRENT_USER is actually an alias/symlink of a key under HKEY_USERS.