gpt4 book ai didi

c++ - 从 VS2012 在 C++ 中使用 ATL 创建 COM

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:52:12 25 4
gpt4 key购买 nike

尝试在 Visual Studio 2012 中使用 ATL 创建简单的 COM 库。我这样做:

 New ATL Project
Welcome to the ATL Project Wizard
Next
Application Settings - no change (DLL)
Next
Finish

enter image description here

得到了很多文件:

enter image description here

试图了解在何处添加可由 COM 用户调用的简单函数。我发现只有一个地方可以使用向导添加功能:

enter image description here

但我发现在参数选择方面缺少一些东西,比如 in、out、retval。 enter image description here

我希望在添加新功能后至少 IDL 文件也会更新,但这并没有发生。

从 VS2012 的 Visual C++ 使用 ATL 创建简单的 COM 类的方法是什么?

最佳答案

  1. 添加一个新类 enter image description here

  2. 填写字段 enter image description here enter image description here

在这一步 SomeObject.h 之后,将创建 SomeObject.cpp 文件并将其添加到您的解决方案中,ISomeObject 接口(interface)声明将是添加到 .idl 文件。

  1. 转到类 View (默认组合 ctrl+shift+C),选择 ISomeObject,添加一个新方法 enter image description here

  2. 填写字段 enter image description here

在这一步之后,someMethod 将被添加到 .idl 文件、.h 文件和 .cpp文件。您所要做的就是在 .cpp 文件中编写 someMethod 的实现。

关于c++ - 从 VS2012 在 C++ 中使用 ATL 创建 COM,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33211156/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com