Partager via


CRegKey::Create

Call this method to create the specified key, if it does not exist as a subkey of hKeyParent.

LONG Create( 
   HKEY hKeyParent, 
   LPCTSTR lpszKeyName, 
   LPTSTR lpszClass = REG_NONE, 
   DWORD dwOptions = REG_OPTION_NON_VOLATILE, 
   REGSAM samDesired = KEY_READ | KEY_WRITE, 
   LPSECURITY_ATTRIBUTES lpSecAttr = NULL, 
   LPDWORD lpdwDisposition = NULL  
) 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.

  • lpszClass
    Specifies the class of the key to be created or opened. The default value is REG_NONE.

  • dwOptions
    Options for the key. The default value is REG_OPTION_NON_VOLATILE. For a list of possible values and descriptions, see RegCreateKeyEx in the Windows SDK.

  • samDesired
    The security access for the key. The default value is KEY_READ | KEY_WRITE. For a list of possible values and descriptions, see RegCreateKeyEx.

  • lpSecAttr
    A pointer to a SECURITY_ATTRIBUTES structure that indicates whether the handle of the key can be inherited by a child process. By default, this parameter is NULL (meaning the handle cannot be inherited).

  • lpdwDisposition
    [out] If non-NULL, retrieves either REG_CREATED_NEW_KEY (if the key did not exist and was created) or REG_OPENED_EXISTING_KEY (if the key existed and was opened).

Return Value

If successful, returns ERROR_SUCCESS and opens the key. If the method fails, the return value is a nonzero error code defined in WINERROR.H.

Remarks

Create sets the m_hKey member to the handle of this key.

Requirements

Header: atlbase.h

See Also

Reference

CRegKey Class

CRegKey::Open

CRegKey::Close