Compartir a través de


CRegKey::Open

Call this method to open the specified key and set m_hKey to the handle of this key.

LONG Open( 
   HKEY hKeyParent, 
   LPCTSTR lpszKeyName, 
   REGSAM samDesired = KEY_READ | KEY_WRITE 
) throw( );

Parameters

  • hKeyParent
    The handle of an open key.

  • lpszKeyName
    Specifies the name of a key to be created or opened. This name must be a subkey of hKeyParent.

  • samDesired
    The security access for the key. The default value is KEY_ALL_ACCESS. For a list of possible values and descriptions, see RegCreateKeyEx in the Windows SDK.

Return Value

If successful, returns ERROR_SUCCESS; otherwise, a non-zero error value defined in WINERROR.H.

Remarks

If the lpszKeyName parameter is NULL or points to an empty string, Open opens a new handle of the key identified by hKeyParent, but does not close any previously opened handle.

Unlike CRegKey::Create, Open will not create the specified key if it does not exist.

Requirements

Header: atlbase.h

See Also

Reference

CRegKey Class

CRegKey::Close