'RegOpenKeyEx function returns access denied error code 5 for reg key path containing'{ }'

I am trying to call RegOpenKeyEx function on reg key path for an app with Read permission in registry. I tested the call with another Reg key without the '{ }' in path and that works.

What am I missing ? 😕

Edit I have also tried requesting different security descriptor: KEY_READ, KEY_QUERY_VALUE. Adding code snippet below. I receive a return code 5. I am able to read other RegKeys from the same process which don't have a {}(receive error code SUCCESS i.e. 0).

LONG retCode = ::RegOpenKeyExW(
        hKeyParent,
        subKey.c_str(),
        REG_NONE,
        STANDARD_RIGHTS_READ,
        &hKey);

    if (retCode != SUCCESS)
    {
        return false;
    }

    Close();

    m_hKey = hKey;

    _ASSERTE(retCode == SUCCESS);
    return retCode == SUCCESS; code here


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source