regGetExpandString function

String regGetExpandString(
  1. int hkey,
  2. String subKey,
  3. String valueName, {
  4. int accessRights = KEY_QUERY_VALUE,
  5. bool expand = true,
})

Retrieves a registry value located at hkey/subKey/valueName that is of type REG_EXPAND_SZ.

If expand is true then any environment variables in the value are expanded. If expand is false then the value is returned un-expanded. A WindowsException is thrown the call falls.

Implementation

String regGetExpandString(
  int hkey,
  String subKey,
  String valueName, {
  int accessRights = KEY_QUERY_VALUE,
  bool expand = true,
}) {
  late final String value;

  var flags = RRF_RT_REG_EXPAND_SZ | RRF_RT_REG_SZ;

  if (!expand) {
    flags |= RRF_NOEXPAND;
  }

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