Export (0) Print
Expand All
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

RegCreateKeyEx

Windows Mobile 6.5
A version of this page is also available for
4/8/2010

This function creates a registry key by using the specified parameters. If the key already exists in the registry, the function opens it.

A remote application interface (RAPI) version of this function exists and is called CeRegCreateKeyEx (RAPI).


LONG RegCreateKeyEx( 
  HKEY hKey, 
  LPCWSTR lpSubKey, 
  DWORD Reserved, 
  LPWSTR lpClass, 
  DWORD dwOptions, 
  REGSAM samDesired, 
  LPSECURITY_ATTRIBUTES lpSecurityAttributes, 
  PHKEY phkResult, 
  LPDWORD lpdwDisposition 
); 

hKey

[in] Handle to a currently open key or one of the following predefined reserved handle values:

  • HKEY_CLASSES_ROOT
  • HKEY_CURRENT_USER
  • HKEY_LOCAL_MACHINE
  • HKEY_USERS

Windows Mobile does not support the HKEY_CURRENT_CONFIG, HKEY_PERFORMANCE_DATA, or HKEY_DYN_DATA predefined reserved handle values.

The key that is opened or created by this function is a subkey of the key that is identified by this parameter.

lpSubKey

[in] Pointer to a null-terminated string that specifies the name of a subkey that this function opens or creates. This is a subkey of the key that is identified by hKey. The subkey must not begin with a backslash (\). If the parameter is set to NULL, the function behaves like RegOpenKey and opens the key that is specified by hKey. In Windows Mobile, the maximum length of a key name is 255 characters, excluding the terminating NULL character. You can nest only16 levels of subkeys in Windows Mobile.

Reserved

[in] Reserved. Set to zero.

lpClass

[in] Pointer to a null-terminated string that specifies the class or object type of this key. This parameter is ignored if the key already exists. In Windows Mobile, the maximum length of a class string is 255 characters, excluding the terminating NULL character.

dwOptions

[in] Registry key options. The following table shows possible values.

Value Description

REG_OPTION_NON_VOLATILE

Default setting. All registry keys are created as nonvolatile, and the information that is stored in memory is preserved when the OS is restarted.

REG_OPTION_VOLATILE

All registry keys are created as volatile, and the information is stored in memory and is not preserved when the corresponding registry hive is unloaded. For HKEY_LOCAL_MACHINE, this occurs when the OS is shut down. This flag is ignored for keys that already exist.

samDesired

[in] Ignored. Set to zero to ensure compatibility with future versions of Windows Mobile.

lpSecurityAttributes

[in] Set to NULL. Windows Mobile automatically assigns the key a default security descriptor.

phkResult

[out] Pointer to a variable that receives a handle to the opened or created key. When you no longer need the returned handle, call the RegCloseKey function to close it.

lpdwDisposition

[out] Pointer to a variable that receives disposition values. The following table shows possible values.

Value Description

REG_CREATED_NEW_KEY

The key did not exist and was created.

REG_OPENED_EXISTING_KEY

The key existed and was opened without being changed.

ERROR_SUCCESS indicates success. A nonzero error code defined in Winerror.h indicates failure. To get a generic description of the error, call FormatMessage with the FORMAT_MESSAGE_FROM_SYSTEM flag set. The message resource used by FormatMessage is an optional component in Windows Mobile. Therefore, FormatMessage might fail.

The key that this function creates has no values. An application can use the RegSetValueEx function to set key values.

An application can use this function to temporarily lock a part of the registry. When the locking process creates a new key, it receives the disposition value REG_CREATED_NEW_KEY, which indicates that it owns the lock. Another process that is trying to create the same key receives the disposition value REG_OPENED_EXISTING_KEY, which indicates that another process already has that section of the registry locked.

Headerwinreg.h
Librarycoredll.lib
Windows Embedded CEWindows CE 1.0 and later
Windows MobileWindows Mobile Version 5.0 and later

Community Additions

Show:
© 2015 Microsoft