|This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.|
As with the desktop version of COM, a thread can call the CoCreateInstanceor the CoGetClassObjectfunction to create a new instance of a component. However, under Windows CE, the dwClsContextparameter in those calls must be set to CLSCTX_ INPROC_SERVER.
Beginning with Windows CE 2.12, you can activate in-process COM objects by specifying either CLSCTX_ ALL or CLSCTX_SERVER; earlier versions of Windows CE will return an E_NOTIMPL error if the flag is not set explicitly to CLSCTX_INPROC_SERVER. Additionally, the COSERVERINFO parameter in the call to the CoGetClassObjectfunction must be NULL, because COM on Windows CE does not support remote servers.
IClassFactory* pFactory = NULL; ::CoGetClassObject(CLSID_MyObject, CLSCTX_INPROC_SERVER, NULL, IID_ICLASSFACTORY, (LPVOID*) &pFactory); pFactory->CreateInstance(NULL,IID_IMyObject, (LPVOID*) m_pObj);
The DCOM implementation requires that you initialize objects by calling the CoInitializeExfunction before you can use them.
The COM implementation does not enforce object initialization, but it is still recommended that you initialize all objects..