The RegCreateKeyEx function creates the specified key. If the key already exists in the registry, the function opens it.
LONG RegCreateKeyEx(
HKEY hKey, |
// handle of an open key |
LPCTSTR lpSubKey, |
// address of subkey name |
DWORD Reserved, |
// reserved |
LPTSTR lpClass, |
// address of class string |
DWORD dwOptions, |
// special options flag |
REGSAM samDesired, |
// desired security access |
LPSECURITY_ATTRIBUTES lpSecurityAttributes, |
// address of key security structure |
PHKEY phkResult, |
// address of buffer for opened handle |
LPDWORD lpdwDisposition |
// address of disposition value buffer |
); |
HKEY_CLASSES_ROOT
HKEY_CURRENT_CONFIG
HKEY_CURRENT_USER
HKEY_LOCAL_MACHINE
HKEY_USERS
Windows NT only: HKEY_PERFORMANCE_DATA
Windows 95 only: HKEY_DYN_DATA
The key opened or created by the RegCreateKeyEx function is a subkey of
the key identified by the hKey parameter.
Value |
Meaning |
REG_OPTION_NON_VOLATILE |
This key is not volatile; this is the default. The information is stored in a file and is preserved when the system is restarted. The RegSaveKey function saves keys that are not volatile. |
REG_OPTION_VOLATILE |
Windows NT: This key is volatile; the information is stored in memory and is not preserved when the system is restarted. The RegSaveKey function does not save volatile keys. This flag is ignored if the key already exists. Windows 95: This value is ignored in Windows 95. If REG_OPTION_VOLATILE is specified, the RegCreateKeyEx function creates a nonvolatile key and returns ERROR_SUCCESS. |
REG_OPTION_BACKUP_RESTORE |
Windows NT: If this flag is set, the function ignores the samDesired parameter and attempts to open the key with the access required to backup or restore the key. If the calling thread has the SE_BACKUP_NAME privilege enabled, the key is opened with ACCESS_SYSTEM_SECURITY and KEY_READ access. If the calling thread has the SE_RESTORE_NAME privilege enabled, the key is opened with ACCESS_SYSTEM_SECURITY and KEY_WRITE access. If both privileges are enabled, the key has the combined accesses for both privileges. Windows 95: This flag is ignored. Windows 95 does not support security in its registry. |
Value |
Meaning |
KEY_ALL_ACCESS |
Combination of KEY_QUERY_VALUE, KEY_ENUMERATE_SUB_KEYS, KEY_NOTIFY, KEY_CREATE_SUB_KEY, KEY_CREATE_LINK, and KEY_SET_VALUE access. |
KEY_CREATE_LINK |
Permission to create a symbolic link. |
KEY_CREATE_SUB_KEY |
Permission to create subkeys. |
KEY_ENUMERATE_SUB_KEYS |
Permission to enumerate subkeys. |
KEY_EXECUTE |
Permission for read access. |
KEY_NOTIFY |
Permission for change notification. |
KEY_QUERY_VALUE |
Permission to query subkey data. |
KEY_READ |
Combination of KEY_QUERY_VALUE, KEY_ENUMERATE_SUB_KEYS, and KEY_NOTIFY access. |
KEY_SET_VALUE |
Permission to set subkey data. |
KEY_WRITE |
Combination of KEY_SET_VALUE and KEY_CREATE_SUB_KEY access. |
Windows NT: The lpSecurityDescriptor member of the structure specifies a security descriptor for the new key. If lpSecurityAttributes is NULL, the key gets a default security descriptor.
Windows 95: The lpSecurityDescriptor member of the structure is
ignored.
Value |
Meaning |
REG_CREATED_NEW_KEY |
The key did not exist and was created. |
REG_OPENED_EXISTING_KEY |
The key existed and was simply opened without being changed. |
If the function succeeds, the return value is ERROR_SUCCESS.
If the function fails, the return value is a nonzero error code defined in WINERROR.H. You can use the FormatMessage function with the FORMAT_MESSAGE_FROM_SYSTEM flag to get a generic description of the error.
The key that the RegCreateKeyEx function creates has no values. An application can use the RegSetValue or RegSetValueEx function to set key values.
The key identified by the hKey parameter must have been opened with KEY_CREATE_SUB_KEY access. To open the key, use the RegCreateKeyEx or RegOpenKeyEx function.
An application cannot create a key under HKEY_USERS or HKEY_LOCAL_MACHINE.
An application can use RegCreateKeyEx to temporarily lock a portion of the registry. When the locking process creates a new key, it receives the disposition value REG_CREATED_NEW_KEY, indicating that it “owns” the lock. Another process attempting to create the same key receives the disposition value REG_OPENED_EXISTING_KEY, indicating that another process already owns the lock.
RegCloseKey, RegCreateKey, RegDeleteKey, RegOpenKey, RegOpenKeyEx, RegSaveKey, SECURITY_ATTRIBUTES
file: /Techref/os/win/api/win32/func/src/f72_4.htm, 11KB, , updated: 2000/4/7 12:19, local time: 2024/9/1 18:14,
3.145.170.2:LOG IN
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://sxlist.com/Techref/os/win/api/win32/func/src/f72_4.htm"> RegCreateKeyEx</A> |
Did you find what you needed? |
Welcome to sxlist.com!sales, advertizing, & kind contributors just like you! Please don't rip/copy (here's why Copies of the site on CD are available at minimal cost. |
Welcome to sxlist.com! |
.