regDeleteValue function

void regDeleteValue(
  1. int hkey,
  2. String subKey,
  3. String valueName
)

Deletes an registry key.

subKey maybe be a path such as Microsoft/Windows valueName is the name of the value stored under subKey A WindowsException is thrown if the delete fails.

Implementation

void regDeleteValue(
  int hkey,
  String subKey,
  String valueName,
) {
  final pName = TEXT(valueName);
  try {
    _withRegKey(hkey, subKey, KEY_WRITE, (hkey, pSubKey) {
      // var sub = TEXT(path)
      final result = RegDeleteValue(hkey, pName);
      if (result != ERROR_SUCCESS) {
        throw WindowsException(HRESULT_FROM_WIN32(result));
      }
    });
  } finally {
    calloc.free(pName);
  }
}