Extensions Reference
Extensions Reference > exRegistry
regOpenKey
bool regOpenKey(string Hive, string Key);
Opens an existing registry key
The REGOPENKEY function attempts to open the specified registry key in the specified hive. If the key doesn't exist this function returns False. If you require the key to be automatically created if it doesn't exist, refer to the exRegistry::regCreateKey function.
Only one registry key may be opened at any one time. You may switch between registry keys by calling REGOPENKEY repeatedly. There is no requirement to call exRegistry::regCloseKey before switching keys as any open key is automatically closed before the new key is opened.
Parameters
Hive
The name of the registry hive you wish to open. Short names and long names are both valid and must be one of:
Short name Long name HKCR HKEY_CLASSES_ROOT HKCU HKEY_CURRENT_USER HKLM HKEY_LOCAL_MACHINE HKCC HKEY_CURRENT_CONFIG HKU HKEY_USERS HKPD HKEY_PERFORMANCE_DATA Key
The name of the key you wish to open. Keys can be specified as paths, for example if the MyPlugin key is a subkey of Plugins, and Plugins is a subkey of Software, you would specify the key as "Software\\Plugins\\MyPlugin". Remember to use escaped double backslashes.
Return Value
True if the key exists and was opened successfully, otherwise False. Remember that a key can exist but can fail to open due to registry permissions. This is a Windows security feature that this extension cannot avoid.
Example Code
// Open the Brass registry key for the current user
if(regOpenKey("HKCU", "Software\\32Bits\\Brass") == True)
{
// Do something
}