In every WTL example, CoInitialize
is called as the first function of WinMain
. I know that WTL is based on ATL, which is closely related to COM, but as I see it, a WTL program can easily not use any COM code (can't it?).
What adds to the confusion is that ATL has classes such as CComCriticalSection
, which has nothing to do with COM, despite the name.
So my question is: is it necessary to call CoInitialize
in a WTL program, even when no COM is explicitly used?
No, CoInitialize
is not a requirement for a WTL application. Many WTL classes are unrelated to COM. Historically, as you mentioned, WTL was tightly connected to ATL, which in turn was a primary framework for COM development, and COM initialization was a natural step because the application was likely to do something with COM anyway.