使用 COM Object/CComPtr 和 STL 时的建议

发布于 2024-08-30 13:53:08 字数 494 浏览 1 评论 0原文

我正在使用 directshow 做一些与 COM 相关的事情,例如:

typedef CComPtr<IBaseFilter> AutoIBaseFilterPtr;
map<CString, AutoIBaseFilterPtr> _filterMap;

存储与 directShow 相关的 com 对象及其友好名称的列表。

找到 这篇文章(参见:问题2)介绍了 VC10 编译器中的更改如何影响以前正常的代码,我想知道在混合 STL 和 CComPtr 时是否还有更多需要注意的事情,或者只是一般来说,混合 STL 和 COM。

任何提示将不胜感激,谢谢

I am doing some COM related things with directshow such as:

typedef CComPtr<IBaseFilter> AutoIBaseFilterPtr;
map<CString, AutoIBaseFilterPtr> _filterMap;

To store a list of directShow related com objects and their friendly name.

After finding this article (See:Problem 2) on how changes in VC10 compiler might effect previously OK code, I am wondering if there are any more things to watch out for when mixing the STL and CComPtr or prehaps just mixing the STL and COM in general.

Any tips would be greatly appreciated, thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小霸王臭丫头 2024-09-06 13:53:08

我能想到的唯一没有提到的小事情是,CComBSTR 以及 CComPtr 都需要 CAdapt,因为它会重载operator& 也是如此。

事实上,重载 operator& 使得 CAdapt 成为必要,因为许多 STL 容器要求获取某个 X 的地址返回一个指向该 X 的指针。

The only slight thing I can think of that hasn't been mentioned is that CAdapt is required for CComBSTR as well as CComPtr, because it overloads operator& too.

In fact, it is overloading operator& that makes CAdapt necessary, as many STL containers require that taking the address of something X returns a pointer to said X.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文