When you think ASP, think...
Recent Articles
All Articles
ASP.NET Articles
Message Board
Related Web Technologies
User Tips!
Coding Tips

Sample Chapters
Commonly Asked Message Board Questions
JavaScript Tutorials
MSDN Communities Hub
Official Docs
Stump the SQL Guru!
XML Info
Author an Article
ASP ASP.NET ASP FAQs Message Board Feedback
Print this page.
Published: Friday, May 26, 2000

Building a Simple COM Component with Visual C++, Part 2

  • Read Part 1

  • Choose to create a DLL from the ATL COM AppWizard In Part 1 we discussed binomial coefficients and how to start the COM component building process in Visual C++. In this part we'll continue to work through the steps of building the COM component! (Interested in learning more about binomial coefficients? Be sure to visit the extended readings!)

    - continued -

    Recall that in Part 1 we left off with selecting to create an ATL COM AppWizard Project named Math. From that first dialog box we are taken into the ATL COM AppWizard, which contains only one step. The Wizard can be seen to the right.

    Make sure you choose to create a DLL and leave the three checkboxes unchecked. When you are ready, click on the Finish button. At that point you will be presented with a dialog box that lists the files the wizard will create. Click OK and the needed skeleton files will automatically be generated.

    While the Wizard has created the skeleton files for the Math project, we still have to create a class in the project that contains the properties and methods we need. To do this, we will add a Simple ATL Object. To do this, go to the ClassView and right click on the Math classes text; select the option New ATL Object. At this point you should be presented with the following dialog box:

    Add a simple ATL object to the Math project.

    Choose to add a simple object and click Next. You will now be taken to a dialog box into which you can enter the properties for the new simple object, as shown below:

    Give a short name of Comb.

    Simply enter the value Comb in the Short Name text box. The rest of the text boxes will be filled out automatically. Note that the ProgID text box has a value of Math.Comb. This is the ProgID we'll use in our ASP page to instantiate our COM component (Server.CreateObject("Math.Comb")). Take a moment to click on the Attributes tab in the above dialog box. This shows the threading model, interface, and aggregation types for the component. For this example, leave the default values selected.

    By adding a new simple ATL object, a class, CComb, has been added to our project. Also the interface IComb has also been added. This interface determines how the outside world (an ASP page, for example) sees the COM component. To add properties and methods to our component we will add methods and properties to this interface. The interface's properties and methods are mapped to public member functions in the class CComb.

    In Part 3 we'll look at how to add the Comb method to our IComb interface and how to tie a CComb member function to this interface method!

  • Read Part 3
  • Read Part 1

  • ASP.NET [1.x] [2.0] | ASPFAQs.com | Advertise | Feedback | Author an Article