使用ATL在VS2012的C ++中创建COM [英] Creating COM using ATL in C++ from VS2012
问题描述
尝试在Visual Studio 2012中使用ATL创建简单的COM库。
我这样做:
pre>
欢迎使用ATL项目向导
下一页
应用程序设置 - 无更改(DLL)
下一页
完成
有很多档案:
尝试理解添加简单函数的位置由COM用户调用。我发现只有一个地方,我可以使用向导添加功能:
但我看到有些参数选择缺失,如in,out,retval。
我希望添加新函数后,至少IDL文件也会更新,
使用VS2012的Visual C ++从ATL创建简单COM类的方法是什么?
解决方案
添加新类别
填写字段
此步骤之后
SomeObject.h
,SomeObject.cpp
文件将被创建并添加到您的解决方案中,ISomeObject
接口声明将添加到.idl
档案。
前往Class View(预设为ctrl + shit + C) $ c> ISomeObject ,添加一个新方法
填写在字段
c $ c> someMethod 将添加到
.idl
文件,.h
文件.cpp
文件。所有你需要做的是在.cpp
文件中编写someMethod
的实现。Trying to create simple COM library using ATL in Visual Studio 2012. I do:
New ATL Project Welcome to the ATL Project Wizard Next Application Settings - no change (DLL) Next Finish
Got a lot of files:
Trying to understand where to add simple function that can be called by COM user. I found only one place where I can add function using wizard:
But I see that something is missing there regarding parameters selection like in,out,retval.
And I was hoping that after adding new function at least IDL file will be updated too, but this not happened.
What is the way of creating simple COM class using ATL from Visual C++ from VS2012 ?
解决方案
Add a new class
Fill in fields
After this step
SomeObject.h
,SomeObject.cpp
files will be created and added to your solution, theISomeObject
interface declaration will be added to the.idl
file.
Go to Class View (ctrl+shit+C by default), select
ISomeObject
, add a new methodFill in fields
After this step the
someMethod
will be added to.idl
file,.h
file and.cpp
file. All you have to do - is to write an implementation ofsomeMethod
in.cpp
file.这篇关于使用ATL在VS2012的C ++中创建COM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!