4
votes

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
Write the IDL by hand and then update the classes to match.Ben
COM methods are exposed via interfaces, which are implemented by objects. You need to add object first (Add ATL Simple Object) using similar wizard). Then you add methods to interface, which will be created for you.Roman R.

1 Answers

4
votes
  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.