What do the output values from CoGetApartmentType mean?

The Co­Get­Apartment­Type function returns two pieces of information, documented as follows:

  • APT­TYPE enumeration value that specifies the type of the current apartment.
  • APT­TYPE­QUALIFIER enumeration value that specifies the type qualifier of the current apartment.

The possible combinations can be deduced from the documentation for APT­TYPE­QUALIFIER, but here they are in table form because people like tables.

Apartment Type Qualifier Meaning
STA NONE Single-threaded apartment
MAINSTA NONE Main single-threaded apartment
MTA NONE Multithreaded apartment, explicitly initialized
MTA IMPLICIT Multithreaded apartment, implicitly initialized
NA NA_ON_STA Neutral apartment entered on STA thread
NA NA_ON_MAINSTA Neutral apartment entered on main STA thread
NA NA_ON_MTA Neutral apartment entered on explicit MTA thread
NA NA_ON_IMPLICIT_MTA Neutral apartment entered on implicit MTA thread

More details can be found in the documentation for APT­TYPE­QUALIFIER.

Comments (7)
  1. pm100 says:

    and in the next posting how about a posting that explains apartments, why they matter, ….

      1. pm100 says:

        Not really, right up front it says ‘ details of apartments not needed, lets assume all STA’. I think there is room to expand on it (if you feel so inclined – you have a good way of distilling MSDN verbiage into succinct walkthroughs)

        1. The preceding sentence says what an apartment is: “In COM, an apartment is a collection of threads that are treated as equivalent from a COM standpoint.”

  2. Yukkuri says:

    What is a neutral apartment?

    1. Rick C says:

      “In neutral apartments, objects follow the guidelines for multithreaded apartments but can execute on any kind of thread. When a thread is running in a neutral apartment, the object’s context is received without causing a thread switch.”

      1. Yukkuri says:

        D’oh! Read before post!

Comments are closed.

Skip to main content