regDeleteKey function

void regDeleteKey(
  1. HKEY hkey,
  2. String subKey
)

Deletes an registry key.

subKey maybe be a path such as Microsoft/Windows A WindowsException is thrown if the delete fails. @Throwing(WindowsException)

Implementation

void regDeleteKey(
  HKEY hkey,
  String subKey,
) {
  final pSubKey = subKey.toNativeUtf16();

  try {
    final result = RegDeleteKeyEx(hkey, PCWSTR(pSubKey), KEY_WOW64_64KEY);
    if (result != ERROR_SUCCESS) {
      throw WindowsException(HRESULT_FROM_WIN32(result));
    }
  } finally {
    calloc.free(pSubKey);
  }
}