Before calling any COM functions, a thread needs to call CoInitialize to load the COM infrastructure (and to enter an apartment). Once a thread calls CoInitialize, the thread is free to call COM APIs.
CoInitializeEx provides the same functionality as CoInitialize and also provides a parameter to explicitly specify the thread's concurrency model. The current implementation of CoInitialize calls CoInitializeEx and specifies the concurrency model as single-thread apartment. Applications developed today should call CoInitializeEx rather than CoInitialize.
OleInitialize
calls
CoInitializeEx
internally
to
initialize
the
COM
library
on
the
current
apartment.
Because
OLE
operations
are
not
thread-safe,
OleInitialize
specifies
the
concurrency
model
as
single-thread
apartment.
Once
the
concurrency
model
for
an
apartment
is
set,
it
cannot
be
changed.
A
call
to
OleInitialize
on
an
apartment
that
was
previously
initialized
as
multithreaded
will
fail
and
return
RPC_E_CHANGED_MODE.