Is “HKLM” an alias for “HKEY_LOCAL_MACHINE”?

No, although HKLM is an abbreviation for HKEY_LOCAL_MACHINE, there is no official statement from Microsoft that it is always equivalent. In fact, it explicitly states that the availability of these shortcuts depend on the software being used and they are generally referred to as "commonly used abbreviations".

There are cases where abbreviating HKEY_LOCAL_MACHINE to HKLM is not permitted, for instance when defining a policy:

The following conditions apply:

  1. The registry path must be enclosed by percent signs (%).
  2. The registry setting must be a REG_SZ or REG_EXPAND_SZ type. If the registry value contains environment variables, these will be expanded when the policy is evaluated.
  3. Do not use HKLM as an abbreviation for HKEY_LOCAL_MACHINE, or HKCU as an abbreviation for HKEY_CURRENT_USER.
  4. A registry path rule can also include a suffix path.

(From the documentation of Software restriction policies, boldness added by me.)


Yes.

HKLM stands for HKEY_LOCAL_MACHINE Variable.

And HKCU stands for HKEY_CURRENT_USER.

They are the same thing.

According to Wikipedia:

There are seven predefined root keys, traditionally named according to their constant handles defined in the Win32 API, or by synonymous abbreviations (depending on applications):

  • HKEY_LOCAL_MACHINE or HKLM
  • HKEY_CURRENT_CONFIG or HKCC (only in Windows 9x and NT)
  • HKEY_CLASSES_ROOT or HKCR
  • HKEY_CURRENT_USER or HKCU
  • HKEY_USERS or HKU
  • HKEY_PERFORMANCE_DATA (only in Windows NT, but invisible in the Windows Registry Editor)
  • HKEY_DYN_DATA (only in Windows 9x, and visible in the Windows Registry Editor)

I would add that with PowerShell, HKLM exists as a mount for HKEY_LOCAL_MACHINE, as such it is mutable. Example

PS > Get-Item HKLM:
Name                           Property
----                           --------
HKEY_LOCAL_MACHINE

PS > Remove-PSDrive HKLM

PS > Get-Item HKLM:
Get-Item : Cannot find drive. A drive with the name 'HKLM' does not exist.