Click to See Complete Forum and Search --> : CoInitialize and CoInitializeEx


Newbie
September 9th, 1999, 02:34 PM
hi, im developing a multithreaded app in NT and i was wondering which would be better for me to use, CoInitialize or CoInitializeEx.

the multithreaded app uses COM objects but does not share them. each thread has its own COM object so there is no problem with syncronization. i am new to COM so im not too familiar with the threading models, and was wondering if anyone can tell me which i should use to initialize COM.

also should i initialize COM in the main thread or in each worker thread separately?
any help would be greatly appreciated
thanks in advance

Tom Lee
September 9th, 1999, 03:58 PM
CoInitialize calls CoInitalizeEx with a flag of COINIT_APARTMENTHREADED. So if you want a multi threaded environment you have to call CoInitalizeEx with the COINIT_MULTITHREADED flag.

If you are doing an out-of-proc server with the multithreaded flag, be sure not to use any MFC stuff as it only supports apartment threaded stuff.