com提倡的就是灵活,只有减少公开性才能减低耦合,在创建COM实例是也是如此,所有的COM实例都是通过CoCreateInstance()函数创建,那么怎么才能通过这一个API创建出自己现有的实例对象呢?
我们可以先看看函数原型
STDAPI CoCreateInstance(
REFCLSID rclsid, //Class identifier (CLSID) of the object
LPUNKNOWN pUnkOuter, //Pointer to controlling IUnknown
DWORD dwClsContext, //Context for running executable code
REFIID riid, //Reference to the identifier of the interface
LPVOID * ppv //Address of output variable that receives
// the interface pointer requested in riid);