RenameAsync method

Pointer<COMObject> RenameAsync(
  1. String desiredName,
  2. int option
)

Implementation

Pointer<COMObject> RenameAsync(String desiredName, int 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, retValuePtr);

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

  WindowsDeleteString(desiredNameHstring);

  return retValuePtr;
}