我有一个关于 CoCreateInstnace() 方法如何定位和创建包含在 COM DLL 中的 CoClass 实例的问题。
根据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();
所以我想知道这是否确实 CoCreateInstnace 是如何实现的?或者它只是一个逻辑等价物?如果它的实际实现不是这样,我完全不明白 CoCreateInstnace 如何仅使用 CLSID 和在 Windows 注册表中注册的一些 DLL 位置信息就可以找到并创建正确的 CoClass 的实例。
感谢您的回复。
最佳答案
请通过在 Visual Studio IDE 中使用调试版的 MSVCRT 库进行调试来检查它。或者,您可以扫描 VC++ 包含头文件
关于c# - 关于 CoCreateInstance() 方法实现的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3487042/