CRegKey::Create

LONG Create( HKEY hKeyParent, LPCTSTR lpszKeyName, LPTSTR lpszClass = REG_NONE, DWORD dwOptions = REG_OPTION_NON_VOLATILE, REGSAM samDesired = KEY_ALL_ACCESS, LPSECURITY_ATTRIBUTES lpSecAttr = NULL, LPDWORD lpdwDisposition = NULL );

Return Value

If successful, returns ERROR_SUCCESS; otherwise, an error value.

Parameters

hKeyParent

[in] The handle of an open key.

lpszKeyName

[in] Specifies the name of a key to be created or opened. This name must be a subkey of hKeyParent.

lpszClass

[in] Specifies the class of the key to be created or opened. The default value is REG_NONE.

dwOptions

[in] Options for the key. The default value is REG_OPTION_NON_VOLATILE. For a list of possible values and descriptions, see RegCreateKeyEx in the Win32 SDK.

samDesired

[in] The security access for the key. The default value is KEY_ALL_ACCESS. For a list of possible values and descriptions, see RegCreateKeyEx.

lpSecAttr

[in] 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).

Remarks

Creates the specified key if it does not exist as a subkey of hKeyParent. Otherwise, Create opens the key.

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

CRegKey OverviewClass Members

See Also   CRegKey::Open, CRegKey::Close