isComInitialized top-level property com

bool get isComInitialized

Returns true if the Component Object Model (COM) is initialized on the current thread.

This function performs a non-invasive probe using CoGetApartmentType. No COM state is modified.

Implementation

bool get isComInitialized => using((arena) {
  final pAptType = arena<Int32>();
  final pAptQualifier = arena<Int32>();
  try {
    CoGetApartmentType(pAptType, pAptQualifier);
    return true;
  } on WindowsException {
    // COM is not initialized on this thread.
    return false;
  }
});