Let’s say my application calls CoInitialize when it starts and CoUninitialize before it exists.
Assuming I have a 3rd party component that’s used by my application and does a similar thing, will this cause some kind of failure?
is it okay to call CoInitialize when that call has already been submitted? will the second call fail? or will it just “let it pass” as it’s already called.
CoInitializewill returnS_FALSEif it has already been initialized in the calling thread. However, for both invocations that returnS_OKandS_FALSEthere needs to be aCoUninitializecall. The number of calls to this functions get counted, and only when the number ofCoUninitializeequals that ofCoInitializeit will actually uninitialize things.So in conclusion, a second call is harmless, and there are no problems with calling this pair of functions more than once.