I have a question about how CoCreateInstnace() met开发者_运维知识库hod locate and create an instance of a CoClass contained in a COM DLL.
Accroding to MSDN:
The CoCreateInstance function provides a convenient shortcut by connecting to the class object associated with the specified CLSID, creating an uninitialized instance, and releasing the class object. As such, it encapsulates the following functionality:
CoGetClassObject(rclsid, dwClsContext, NULL, IID_IClassFactory, &pCF);
hresult = pCF->CreateInstance(pUnkOuter, riid, ppvObj)
pCF->Release();
So I am wondering if this is exactly how CoCreateInstnace is implemented? Or is it just a logic equivalent? If its real implementation is not like this, I am totally confused about how CoCreateInstnace could find and make an instance of the proper CoClass with merely a CLSID and some DLL location information registered in the Windows registry.
Thanks for your reply.
Please check it by debugging with debug version of MSVCRT libraries within the Visual Studio IDE. Alternatively, you can scan the VC++ include header files
精彩评论