Initializes the COM library for use by the calling thread, sets the thread’s concurrency model, and creates a new apartment for the thread if one is required.
You should call Windows::Foundation::Initialize to initialize the thread instead of CoInitializeEx if you want to use the Windows Runtime APIs or if you want to use both COM and Windows Runtime components. Windows::Foundation::Initialize is sufficient to use for COM components.
HRESULT CoInitializeEx(
_In_opt_ LPVOID pvReserved,
_In_ DWORD dwCoInit
);
Return value
This function can return the standard return values E_INVALIDARG, E_OUTOFMEMORY, and E_UNEXPECTED, as well as the following values.
CoInitializeEx是 Windows提供的API函数,为当前线程初始化COM库并设置并发模式 。应用程序调用com库中的函数(除CoGetMalloc和内存分配函数)之前必须初始化com库。