regCreateKey function
Creates a registry key.
Throws a WindowsException if the key cannot be created.
@Throwing(WindowsException)
Implementation
void regCreateKey(
HKEY hKey,
String subKey,
) {
final pOpenKey = calloc<Pointer>();
final pSubKey = subKey.toNativeUtf16();
try {
final result = RegCreateKeyEx(
hKey,
PCWSTR(pSubKey),
null,
REG_OPTION_NON_VOLATILE,
KEY_QUERY_VALUE,
null, // not inheritable
pOpenKey,
nullptr);
if (result != ERROR_SUCCESS) {
throw WindowsException(HRESULT_FROM_WIN32(result));
}
HKEY(pOpenKey.value).close();
} finally {
calloc
..free(pOpenKey)
..free(pSubKey);
}
}