当前位置:网站首页>COM编程入门1-创建项目并编写接口
COM编程入门1-创建项目并编写接口
2022-07-21 10:01:00 【宇龍_】
以下项目的构建与开发使用的是vs2010,与vs2015、2017区别不大
1、创建ATL项目并命名为test1
2、应用程序类型选择动态链接库
3、右键项目属性添加类并选择ATL简单对象,命名为Func
4、选择自定义接口
5、 按Ctrl+Shift+C 切换到类视图,右键IFunc类并添加方法,先编写一个整数求和的接口Add
该接口一共三个参数,[in LONG n1,in LONG n2,out retval LONG* pRet]
其中pRet是返回值,是将n1和n2求和后的结果,以LONG的指针作为参数传入函数
6、创建接口完成后,在类视图模式下点击CFunc类,再点击Add接口,跳转到接口的实现,对接口实现进行修改
7、实现Cat接口(字符串拼接接口,参考Add接口的创建)
共三个参数[in BSTR str1,in BSTR str2,out retval BSTR* pRet]
与Add接口一样,第三个参数是前两个参数拼接后的结果
8、编译通过(如果未编译通过,可能是注册COM失败,需要用管理员运行visual studio后再编译),下一篇我们将讲述如何调用自己编写的COM接口
边栏推荐
- 这价格够香!灵耀14 2022影青釉秒杀:12代酷睿+2.8K OLED屏
- 复旦大学白悦辰课题组诚聘博士后、科研助理
- Un7.20: how to display two attributes in an association table at the same time?
- H3C交换机查看相关的命令
- 【Skynet】vs2019调试skynet(修改vs2013工程)
- I, AI doctoral student, online crowdfunding research topic
- [wechat applet] textarea multi line input box (80/100)
- H5 website access wechat payment (H5 payment +jsapi payment)
- hi和hello两个请求引发的@RequestBody思考
- 70. 爬楼梯:假设你正在爬楼梯。需要 n 阶你才能到达楼顶。 每次你可以爬 1 或 2 个台阶。你有多少种不同的方法可以爬到楼顶呢?
猜你喜欢
Quartz simple usage and its es job
VLAN与三层交换机
Flink应用案例统计实现TopN的两种方式
工程效能CI/CD之流水线引擎的建设实践
Construction practice of pipeline engine of engineering efficiency ci/cd
Grafana visual configuration chart table
[H3C device networking configuration]
SQL daily practice (Niuke new question bank) - day 3: condition query
It takes only 10 pictures to figure out how the coupon architecture evolved!
mysql.h: No such file or directory
随机推荐
VMware Workstation Pro virtual machine network three types of network cards and their usage
MySQL performance optimization (III): in depth understanding of indexing
Redis单线程为什么还能这么快
完美+今日头条笔试题+知识点总结
博士申请 | 香港城市大学刘晨老师组招收机器学习方向全奖博士/博后/硕士/RA...
SQL server数据库增量更新是根据 where 子句来识别的吗? 那做不到流更新吧? 每个表要
Number of pairs (dynamic open point)
MobileViT:挑战MobileNet端侧霸主
H3C交换机查看相关的命令
Leetcode 104. 二叉树的最大深度
Interview Beijing XX technology summary
Did someone cut someone with a knife on Shanghai Metro Line 9? Rail transit public security: safety drill
辛丑年之万家灯火
Grafana visual configuration chart table
MySQL. Pas de fichier ou de répertoire
[Skynet] vs2019 debug Skynet (modify vs2013 project)
Read / write operation of trust file
目录和文件管理
RichView Table 表格对齐
荐号 | 真正的卓越者,都在践行“人生最优策略”,推荐这几个优质号