getStringAt method

String getStringAt(
  1. int index
)

Implementation

String getStringAt(int index) {
  final retValuePtr = calloc<HSTRING>();

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

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

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