getNamedBooleanOrDefault method

bool getNamedBooleanOrDefault(
  1. String name,
  2. bool defaultValue
)

Implementation

bool getNamedBooleanOrDefault(String name, bool defaultValue) {
  final retValuePtr = calloc<Bool>();
  final nameHstring = convertToHString(name);

  try {
    final hr =
        ptr.ref.vtable
                .elementAt(11)
                .cast<
                    Pointer<
                        NativeFunction<
                            HRESULT Function(Pointer, IntPtr name,
                                Bool defaultValue, Pointer<Bool>)>>>()
                .value
                .asFunction<
                    int Function(Pointer, int name, bool defaultValue,
                        Pointer<Bool>)>()(
            ptr.ref.lpVtbl, nameHstring, defaultValue, retValuePtr);

    if (FAILED(hr)) throw WindowsException(hr);

    final retValue = retValuePtr.value;
    return retValue;
  } finally {
    WindowsDeleteString(nameHstring);

    free(retValuePtr);
  }
}