Active Template Library (ATL) is a light weight library used to develop COM based components using Visual C++. Through ATL we can quickly develop COM components or COM services.
This article I am trying to explain the steps to create an ATL COM component using Microsoft Visual C++ and Microsoft Visual Studio 2012 IDE (Integrated Development Environment).
Step 1. Open Visual Studio 2012 IDE.
Step 2. Click on File menu. Visual Studio will display a pull-down menu.
Step 3. From pull-down menu, select New menu item. This will show a sub-menu.
Step 4. From sub-menu, select “New Project…” menu item. Visual Studio will display “New Project” dialog; where it displays project types in left side pane; once the project type is selected, its associated templates are displayed in its middle pane.
Step 5. Select Installed node from left side pane. Visual Studio expands the node and show its sub-nodes.
Step 6. Select ATL project type under “Visual C++” sub-node. Visual Studio displays “ATL Project” template in middle pane. Select “ATL Project” template. This template will create an ATL project to enabled to use Active Template Library (ATL).
Step 7. Now we need to name the project and select the location where we want to store the project.
- Enter name of the project in “Name:” field.
- Select the location where to store the project in “Location:” field. If know the path where to store the project, we can directly enter the path in “Location:” field. Otherwise, select the “Browse…” button to select the location where to store the created project from “Project Location” dialog.
- Provide the solution name in “Solution name:” field.
- Check “Create directory for solution” checkbox. This will create a solution and projects in different folders. Otherwise, solution and projects will create in the same folder.
Step 8. Click on OK button to create the ATL based project. Visual Studio will start creating the project. It will display “ATL Project Wizard” dialog to allow to select application settings.
Step 9. Click on Next button on “ATL Project Wizard” dialog to go to “Application Settings” wizard.
Step 10. From “Application Settings” wizard:
- Select “Dynamic-link library (DLL)” option; which is under “Application type:” group. This option will create a DLL project. That means, we cannot run the project as self-executable. But we can load this project into the other applications. To create it as an executable select EXE as an application type.
- To support MFC (Microsoft Foundation Classes) framework, select “Support MFC” checkbox from “Support options:” options.
- Then click on Finish button.
Visual Studio will create a project and generates some code. We have created our project using “ATL Project” template; so, this template creates most of the common functionality of COM component to make our job much easier. That means, for example, we no need to write a functionality to register the ATL COM component with registry; because the functionality has been written for us already.
Now we need to add our functionality to the project. We will discuss it in our next article.