c++ - IClassFactory::CreateInstance 方法的 pUnkOuter 参数

标签 c++ generics com

IClassFactory::CreateInstance 方法的pUnkOuter 参数背后的原因是什么?

HRESULT CreateInstance(
  [in]   IUnknown *pUnkOuter,
  [in]   REFIID riid,
  [out]  void **ppvObject
);

MSDN对pUnkOuter参数说明的说明:

If the object is being created as part of an aggregate, specify a pointer to the controlling IUnknown interface of the aggregate. Otherwise, this parameter must be NULL.

请问各位大神,请问这个参数是做什么用的?

最佳答案

参见 Aggregation在 COM 基础知识中。如果您创建作为聚合一部分的 COM 对象实例,则必须提供所谓的“外部 IUnknown”,它是所有者 COM 对象接口(interface)。

关于c++ - IClassFactory::CreateInstance 方法的 pUnkOuter 参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7595263/

相关文章:

c# - 派生类定义的基类集合

c++ - 进入拖放过程(或任何其他系统调用)

c++ - CoCreateInstance() 永远不会返回

c++ - 套接字不发送所有二进制数据

c++ - 使用保存的客户端 ip 地址将数据包从服务器发送到特定客户端?

java - 如何在 Java 中将 int[] 转换为 Integer[]?

Scala 工厂模式根据泛型类型返回具体类

c# - Microsoft Word 中的 SaveCopyAs 行为

c++ - ostream& 和 istream& 未正确定义

c++ - 如何对通用列表提取进行元编程以构建函数调用