renameAsyncOverloadDefaultOptions method

Future<void> renameAsyncOverloadDefaultOptions(
  1. String desiredName
)

Implementation

Future<void> renameAsyncOverloadDefaultOptions(String desiredName) {
  final retValuePtr = calloc<COMObject>();
  final completer = Completer<void>();
  final desiredNameHstring = convertToHString(desiredName);

  final hr = ptr.ref.vtable
          .elementAt(6)
          .cast<
              Pointer<
                  NativeFunction<
                      HRESULT Function(Pointer, IntPtr desiredName,
                          Pointer<COMObject>)>>>()
          .value
          .asFunction<
              int Function(Pointer, int desiredName, Pointer<COMObject>)>()(
      ptr.ref.lpVtbl, desiredNameHstring, retValuePtr);

  if (FAILED(hr)) {
    free(retValuePtr);
    throw WindowsException(hr);
  }

  WindowsDeleteString(desiredNameHstring);

  final asyncAction = IAsyncAction.fromRawPointer(retValuePtr);
  completeAsyncAction(asyncAction, completer);

  return completer.future;
}