getNamedString method

String getNamedString(
  1. String name
)

Implementation

String getNamedString(String name) {
  final retValuePtr = calloc<HSTRING>();
  final nameHstring = convertToHString(name);

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

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

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