Introduced
The purpose of this tutorial is to show you how to create a COM server using ATL and use Visual C + + and Visual Basic programs to call this server separately. I don't want to delve into the details of COM, nor do I want you to get bogged down in IDL. This tutorial is designed for VC + + novice programmers, telling them how easy it is to use ATL to create a COM object and allow them to have more interest in ATL.
Step 1th: Start the ATL COM Wizard
The first thing you need to do is start Visual C + + and create a new project, select ATL COM Wizard, and project name "Simple_atl". After you have set the path for the project, click the OK button. You will see that the screen gives you several options. The first option is "Server Type." We are going to create a server DLL, so make sure the server type is selected as the Dynamic Link Library. We don't need to care about the other three check boxes below, so we can ignore them. Press the Finish button so that the wizard will produce the appropriate files for you. After that, a New Project information window appears, and you can tell from above what files The wizard will create and press "OK" to accept all of this.
Step 2nd: Create a new ATL object
Please make sure you can see Workspace view in the VC + + IDE, and if not, click the "View" menu and choose "Workspace". In this view you will see three tabs, please click the "ClassView" bar, you should see "Simple_atl Classes". Right-click here and choose New ATL Object in the pop-up menu, and you will see the following window:
The default selection "Simple Object" is what we want, please click the Next button and you will come to the ATL Object Wizard Properties window. Enter "First_atl" in the Short Name text box. Note that the wizard will automatically fill in the other text boxes. Then, click the "Attributes" tab at the top, where you need to make some choices. For the first threading model (Threading models), we select the default unit (Apartment) model. For interfaces (Interface), we choose double (Dual). Finally, because our program has nothing to do with aggregation (Aggregation), we select the radio button "No". You don't have to care about the three check boxes at the bottom, just click OK, and the wizard will create a new ATL simple object for us.