如何使用COM智能指针作为内外参数来调用例如库函数
How to use COM smart pointer as in-out arguments for calling e.g. library functions
使用CComPtr或_com_ptr智能指针作为输入输出参数的最佳方式是什么?
void FunctionPrototype(Test** test) {
// you can use here test or create a new Test here and assign to test
}
CComPtr<Test> test;
test.CoCreateInstance(..., ..., ...);
test->SetValue(10);
FunctionPrototype(&test); // assertion since test.p is not NULL
CComPtr<T>::operator&
:的定义旁边有一条注释
对运算符&通常表示存在错误。如果这真的然而,需要的是显式地获取p成员的地址。
所以使用调用您的函数
FunctionPrototype(&test.p);
相关文章:
- 当对话框被接受时,如何用参数调用槽
- 使用用户定义的参数调用future/async并调用类方法
- 我使用向量来创建类对象列表.初始化向量时如何使用参数调用构造函数?
- 将成员函数作为构造函数参数调用时出错 "Variable is not a type name"
- 不允许运算符 const 参数调用 const 成员函数
- 为变量模板的每个参数调用模板函数
- 如何在窗口中使用注入的 dll 中的参数调用函数
- 按引用调用与按指针参数调用的差异 前递增和后递增
- 为什么使用不匹配的参数调用重载函数仍然有效
- PowerShell 使用结构类型参数调用 C++ DLL 的导出函数
- 基于枚举参数调用专用模板方法
- C++ 如何根据作为输入传递的参数调用一个构造函数或另一个构造函数?
- 如何使用类模板参数来更改参数调用和函数签名?
- lambda 函数使用其参数作为模板参数调用模板函数
- Android:使用 c++ 中的 byte[] 参数调用 java 方法
- 使用不同的模板参数调用模板类的对象
- C++编译时检查是否可以用某种类型的参数调用重载函数
- 是否可以基于类模板的参数调用类方法和全局方法
- 使用单独的参数调用"boost::process::system()"时,获取"execv
- C++大括号初始值设定项作为参数调用不同的构造函数,然后预期