In WinAPI, CoInitializeEx
requires dwCoInit
parameter such as COINIT_APARTMENTTHREADED
or COINIT_MULTITHREADED
.
The term "APARTMENTTHREADED" seems confusing as both STA (Single Threaded Apartment) or MTA (Multi Threaded Apartment) are apartments.
If COINIT_APARTMENTTHREADED
means STA, can anyone give official document that clarifies it?
AFAIK, COINIT_APARTMENTTHREADED
is simply described as "Initializes the thread for apartment-threaded object concurrency".
It seems "COINIT_STA and COINIT_MTA" or "COINIT_SINGLETHREADED" and "COINIT_MULTITHREADED" delivers its meaning more precisely.
Yes COINIT_APARTMENTTHREADED
is for STA, and COINIT_MULTITHREADED
is for MTA.
The apparent discrepancy (missing the word "apartment" in the latter) is probably due to slight change in COM terminology over the years.
In any case you asked for some official documentation that confirms this, so here it is:
The documentation for Single-Threaded Apartments, explicitly mentions that COINIT_APARTMENTTHREADED
should be used with CoInitializeEx
.
The documentation for Multithreaded Apartments, explicitly mentions that COINIT_MULTITHREADED
should be used with CoInitializeEx
.
Regarding:
It seems "COINIT_STA and COINIT_MTA" or "COINIT_SINGLETHREADED" and "COINIT_MULTITHREADED" delivers its meaning more precisely.
That might be true, but since MS would like to maintain backwards compatibility it is problematic to change these identifier names (which are quite ancient, and widely used).
BTW - As @IInspectable commented above, MS seems to agree with you in principle, since for the newer RoInitialize
API they chose identifier names along the lines of your suggestion: RO_INIT_SINGLETHREADED
, RO_INIT_MULTITHREADE
.