toInterface method

Pointer<COMObject> toInterface(
  1. String iid
)
inherited

Cast an existing COM object to a specified interface.

Takes a string (typically a constant such as IID_IModalWindow) and does a COM QueryInterface to return a reference to that interface.

Implementation

Pointer<COMObject> toInterface(String iid) {
  final pIID = convertToIID(iid);
  final objectPtr = calloc<COMObject>();

  try {
    final hr = queryInterface(pIID, objectPtr.cast());
    if (FAILED(hr)) throw WindowsException(hr);
    return objectPtr;
  } finally {
    free(pIID);
  }
}