4.1 Reading a Registry Key and Value

The operations in reading a registry key and value are as follows:

  • The client obtains a handle to one of the root keys, for example HKEY_LOCAL_MACHINE, by using the OpenLocalMachine method.

  • The client uses the handle to the root key with the BaseRegOpenKey method to open a subkey. The BaseRegOpenKey method returns a handle to the subkey.

  • The client uses the handle to the subkey to read values under the subkey by using the BaseRegQueryValue method. The client uses the value for client-specific operations.

  • After all required keys and values have been read, the client closes the open handles by using the BaseRegCloseKey method.