Creating COM using ATL in C++ from VS2012

2019-06-24 01:39发布

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

enter image description here

Got a lot of files:

enter image description here

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:

enter image description here

But I see that something is missing there regarding parameters selection like in,out,retval. enter image description here

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 ?

1条回答
【Aperson】
2楼-- · 2019-06-24 02:15
  1. Add a new class enter image description here

  2. Fill in fields enter image description here enter image description here

After this step SomeObject.h, SomeObject.cpp files will be created and added to your solution, the ISomeObject interface declaration will be added to the .idl file.

  1. Go to Class View (the combination ctrl+shift+C by default), select ISomeObject, add a new method enter image description here

  2. Fill in fields enter image description here

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 of someMethod in .cpp file.

查看更多
登录 后发表回答