CodeSteps

Python, C, C++, C#, PowerShell, Android, Visual C++, Java ...

Visual C++ – Creating an ATL COM Component (Part – 1)

Active Template Library (ATL) is a lightweight library used to develop COM-based components using Visual C++. Through ATL we can quickly develop COM components or COM services.

In 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 the File menu. Visual Studio will display a pull-down menu.

Visual Studio - File - New menu
Visual Studio – File – New menu

Step 3. From the pull-down menu, select New menu item. This will show a sub-menu.

Step 4. From the sub-menu, select the “New Project…” menu item. Visual Studio will display the “New Project” dialog; where it displays project types in the left side pane; once the project type is selected, its associated templates are displayed in its middle pane.

Visual Studio 2012 – “New Project” dialog – “ATL Project” template

Step 5.  Select Installed node from left side pane. Visual Studio expands the node and shows its sub-nodes.

Step 6. Select the ATL project type under the “Visual C++” sub-node. Visual Studio displays the “ATL Project” template in the middle pane. Select the “ATL Project” template. This template will create an ATL project to enable to use of 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 the name of the project in the “Name:” field.
  • Select the location where to store the project in the “Location:” field. I know the path where to store the project, we can directly enter the path in the “Location:” field. Otherwise, select the “Browse…” button to select the location where to store the created project from the “Project Location” dialog.
  • Provide the solution name in the “Solution name:” field.
  • Check the “Create the directory for solution” checkbox. This will create a solution and projects in different folders. Otherwise, solutions and projects will create in the same folder.

Step 8. Click on the OK button to create the ATL-based project. Visual Studio will start creating the project. It will display the “ATL Project Wizard” dialog to allow to selection of application settings.

Visual Studio 2012 – “ATL Project Wizard” – Overview wizard

Step 9. Click on the Next button on the “ATL Project Wizard” dialog to go to the “Application Settings” wizard.

Step 10. From the “Application Settings” wizard:

Visual Studio 2012 – “ATL Project Wizard” – “Application Settings” wizard
  • Select the “Dynamic-link library (DLL)” option; which is under the “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 the “Support MFC” checkbox from the “Support options:” options.
  • Then click on the Finish button.

Visual Studio will create a project and generate some code. We have created our project using the “ATL Project” template; so, this template creates most of the common functionality of the COM component to make our job much easier. That means, for example, we no need to write functionality to register the ATL COM component with the 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.

**

Visual C++ – Creating an ATL COM Component (Part – 1)

3 thoughts on “Visual C++ – Creating an ATL COM Component (Part – 1)

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top
Exit mobile version