RegCreateKeyEx (coredll)
Last changed: fabio_rodrigues@student-partners.com-62.28.79.25

.
Summary
Creates the specified key. If the key already exists in the registry, it is opened.

C# Signature:

[DllImport("coredll.dll")]
public static extern int RegCreateKeyEx(
   IntPtr hKey, string lpSubKey, uint dwReserved, string lpClass,
   uint dwOptions, int samDesired, IntPtr lpSecurityAttributes,
   out IntPtr phkResult, out RegistryDispositionValue lpdwDisposition);

User-Defined Types:

enum RegistryDispositionValue : uint
{
   REG_CREATED_NEW_KEY     = 0x00000001,
   REG_OPENED_EXISTING_KEY = 0x00000002
}

Notes:

The .NET Compact Framework does not contain a HandleRef type, so it may be necessary to call GC.KeepAlive after calling this function if the calling class wraps the hKey parameter as an unmanaged resource.

Tips & Tricks:

None.

Alternative Managed API:

CF V2.0

Microsoft.Win32.Registry.LocalMachine.CreateSubKey(SubKey as string)

Documentation