regGetString function Null safety

String regGetString(
  1. int hkey,
  2. String subKey,
  3. String valueName,
  4. {int accessRights = KEY_QUERY_VALUE}
)

Gets a Windows registry value o0f type REG_SZ hkey is typically HKEY_CURRENT_USER or HKEY_LOCAL_MACHINE.

See the following link for additional values: https://docs.microsoft.com/en-us/windows/win32/sysinfo/predefined-keys

subKey is name of the registry key you want to open. This is typically something like 'Environment'.

accessRights defines what rights are requried for the opened key. This is typically one of KEY_ALL_ACCESS, KEY_QUERY_VALUE, KEY_READ, KEY_SET_VALUE Refer to the following link for a full set of options. https://docs.microsoft.com/en-us/windows/win32/sysinfo/registry-key-security-and-access-rights

throws WindowsException if the get failes

Implementation

String regGetString(
  int hkey,
  String subKey,
  String valueName, {
  int accessRights = KEY_QUERY_VALUE,
}) {
  late final String value;

  final pResult =
      _regGetValue(hkey, subKey, valueName, accessRights: accessRights);
  try {
    value = pResult.toDartString();
  } finally {
    pResult.free();
  }
  return value;
}