renameAsync method

Pointer<COMObject> renameAsync(
  1. String desiredName,
  2. NameCollisionOption option
)

Implementation

Pointer<COMObject> renameAsync(
    String desiredName, NameCollisionOption option) {
  final retValuePtr = calloc<COMObject>();
  final desiredNameHstring = convertToHString(desiredName);

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

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

  return retValuePtr;
}