Home > Store

COM and COM+ Programming Primer, The

Register your product to gain access to bonus material or receive a coupon.

COM and COM+ Programming Primer, The


  • This product is temporarily unavailable.
Not for Sale


  • Copyright 2000
  • Dimensions: 7" x 9-1/4"
  • Edition: 1st
  • Book
  • ISBN-10: 0-13-085032-2
  • ISBN-13: 978-0-13-085032-4


Learn how to build 3-tiered, thin-client application with COM+ and the Windows DNA 2000

  • Extensive coverage of COM+
  • Step-by-step instructions show you how to build Components that use COM+ Services: Fine-grained security, transactions, synchronization, queued components, and loosely coupled events
  • Learn how to integrate all the technologies in the Windows DNA 2000: COM+, ASP, IIS, SQL Server, OLEDB, ADO, and XML
  • Starts from first principles-no need to understand COM already
  • Build on your skill base with Visual C++® and Visual Basic®

COM+ is the second generation of COM. It includes new features that make COM easier to use and simplifies the development of distributed, enterprise-class applications. COM+ builds on the distributed infrastructure provided by DCOM and MTS, and it represents the evolution of COM from a desktop, application integration technology to a distributed, application development infrastructure.

In The COM and COM+ Programming Primer, you'll follow an experienced instructor and programmer/developer through COM+ and COM code from the "inside out," so you understand its deep structure. You'll build simple objects from scratch to gain a thorough familiarity with the underlying concepts. Your existing skills in Visual Basic and Visual C++ will help you master COM and COM+ so you'll be creating usable applications in record time.

With Alan Gordon's straightforward explanations and practical use of standard tools, you'll get the in-depth knowledge you need to create applications that leverage COM+ and all the technologies in the Windows DNA 2000.

Sample Content

Downloadable Sample Chapter

Click here for a sample chapter for this book: 0130850322.pdf

Table of Contents

(NOTE: Each chapter concludes with Summary.)


1. What's in a Name?

COM. DCOM. MTS. Windows DNA. COM+. ActiveX. OLE.

2. Classes, Objects, and Interfaces.

What is Object-Orientation? Classes. Objects. Interfaces.

3. Get on the Software Bus.

Software Bus Problems.

4. Building Your First COM Object.

The Simple Spell Checker. A Summary of the Steps. Creating a New DLL Project Using Visual C++. Creating a Custom Interface Using IDL. Declaring a C++ Class That Implements the COM Interface. Implementing the SpellChecker Interface. Creating a Class Object. Creating the Required DLL Entry-Points. Creating the Registration Functions. Creating a Client.

5. Making It Simple with ATL and Visual C++ COM Native Support.

A Quick Introduction to ATL. The Writer's Component. Creating an ATL Project Using the ATL/COM AppWizard. Adding the Document Checker COM Class Using the ATL Object Wizard. Implementing ISpellChecker. Implementing IgrammarChecker. Creating a Client with Visual C++'s Native COM Support.


6. Creating an Out-of-Process Server.

Marshaling. Instancing. Class Object Registration. Registering an Out-of-Process Server. Building an Out-of-Process Server. A Summary of the Steps.

7. Automation.

Defining Automation. Idispatch. Defining Idispatch Interfaces. Variants. Dual Interfaces. Building an Automation Server. A Summary of the Steps.

COM Callbacks and Connectable Objects.

Understand COM Callbacks/Events. Connectable Objects. Implementing Connection Points. The Connection Point Protocol. Your Multithreaded Stock Monitor Example.

9. COM Threading.

Definitions and Background. Multi-Threading and COM. Implement Objects That Will Run in Any STA. Implement Objects That Will Run in the Primary STA. Implement Objects That Will Run in the MTA. Implement Objects That Will Run in the TNA. Compare the Different Threading Models: An Apartment Study.

10. Distributed COM.

The Importance of DCOM. Location Transparency Revisited. Security. Example: Configuring a Server via DCOM.


11. An Introduction to the COM+ Architecture.

Why Do You Need COM+? Application Architecture. The COM+ Solution. How It Works: The COM+ Architecture. Configure an Object to Use COM+.

12. An Introduction to the COM+ Services.

Fine-Grained Security. Transactions. Scalabilty. Synchronization. Queued Components. Load Balancing. Compensating Resource Managers.

13. Building a 3-Tiered Application Using COM+ and Windows DNA 2000.

What is the Windows DNA? The Windows DNA 2000. Creating Your First COM+ Application. The Publisher Example Program. Building the Publisher Example Application. Object Pooling. Deploying COM+ Application. Differences Between COM+ and MTS. Debugging with COM+.

14. Queued Components.

What are Queued Components? Why Do You Need Queued Components? Microsoft Message Queue. Installing and Using MSMQ. Using Queued Components in Your Example Program.

15. COM+ Events.

Why Do You Need COM+ Events? COM+ Events. Using Queued Components with Events. COM+ Events and Transactons. Filtering Events. Using COM+ Events in a Distributed Environment. Your COM+ Stock Monitoring Program.




Teaching my class at UCLA, an Introduction to COM/ActiveX Programming Using Visual C++, has given me a good background from which to write a book on COM and COM+. The target audience for this book is the same people who took my class at UCLA: intermediate-to-advanced programmers who have little or no knowledge of COM or COM+. By the time you finish this book, you should have enough knowledge of COM to begin using COM and COM+ professionally.

My Approach

My objective is to teach you the 90 percent of COM that, as an application developer, you will use every day. Most of this is surprisingly simple. But there is another 10 percent of COM that is very difficult to understand and this is the part with which I have often seen otherwise excellent programmers become bogged down. It's not that these "10 percent" topics aren't important, it's just that you can get started and begin using COM without understanding all of these topics. Some "10 percent" topics that immediately come to mind are Apartments, custom marshaling, aggregation in general, manual marshaling of interface pointers, and aggregating the Free-Threaded Marshaler. I do cover all of these topics in this book, but be forewarned you probably won't understand these topics the first time you try to learn them; I certainly didn't. But don't get discouraged and don't let topics like this "bog you down" as you try to learn COM. This is not what COM and COM+ is all about. COM is about making it simple for you to build location transparent and programming-language independent software components. COM+ is all about facilitating the development of enterprise-class, distributed applications. The objective of neither of these technologies is to aggregate the Free-Threaded Marshaler. Don't allow yourself to become lost in the minutia of COM as many people do. When I cover topics that I know tend to bog down people (like Apartments), I caution you to just keep going if you don't understand it right away. Please follow this advice. You will understand the other concepts as you begin using COM professionally and start tackling more difficult problems.

Visual C++ and Visual Bask
The primary programming language used in this book is Visual C++. The world seems to be turning away from languages like Visual C++ and to languages like Visual Basic, Java, and Delphi. Unfortunately these languages hide so much of the under-lying details of COM that it is difficult to understand what's going on under the hood if you only use these languages. Only in Visual C++ can you implement the IUnknown interface, and create your own class factory, as you will do in Chapter 4. I strongly believe that the additional insight that you gain by doing this is well worth the additional complexity. In addition, there are certain things that you can do in COM+ that you simply cannot do from Visual Basic 6, such as building an object that will run in the thread-neutral apartment and using object pooling. Once you understand COM+ using Visual C++, transferring your knowledge to a more productive development environment, like Visual Basic, will be easy. Don't worry; you don't have to be a C++ Guru to read this book. I really think that a beginning C++ programmer will have little problem following along with the code in this book. I do use Visual Basic to build some of the client programs. I mainly did this to save time. It is much easier to build GUIs with Visual Basic than Visual C++. In addition, using Visual C++ for server-side development and Visual Basic for client-side development is a popular combination that I have seen on a number of projects recently.

Use of the Word Component
If you read any books about COM you quickly see that the word component has two popular uses:

  • It refers to a binary file (a Dynamic Link Library or Executable) that implements one or more COM classes
  • it refers to a single COM class

Personally, I prefer the first definition of the word mainly because I believe that a COM class adequately describes the individual pieces of functionality that may reside in a single binary. People who use component to refer to a COM class usually use component server or just server to refer to the binary in which several components may be hosted. When you start using COM+ you will see that Microsoft refers to COM+ classes as components (even though they are not completely consistent either). I'm hardly a zealot on these kinds of issues so I concede the argument for now. I think there still are a few places in this book where my old bias shows through. I believe that in all places it is obvious from the context whether I am referring to a single COM class or a binary file in which several classes reside.

The Book's Structure

Of the 15 chapters in this text, eight chapters (1-8) are essentially pure COM, two chapters (9 and 10) are primarily COM with some COM+, and five chapters (chapters 11-15) are pure COM+. The simple reality is that you cannot understand COM+ without first understanding COM. COM+ is really just a vastly improved and more tightly integrated version of Microsoft Transaction Server along with some key refinements to the underlying COM infrastructure such as Thread Neutral Apartments. A book that only covered COM+ features would only be usable by people who understand COM already. I covered both COM and COM+ because I wanted this book to be usable by people who are new to COM. Having said that, I teach you only enough COM so that you can understand COM+. COM+ was designed primarily to facilitate the development of enterprise-class, distributed applications, so there are many COM topics (ActiveX controls for instance) that are not covered in this book because they have little relevance to enterprise-class development and COM+.

Most of the chapters start by explaining a problem that can be resolved by using COM/COM+. That is followed by a discussion of how the COM-related technology works and how you will use it. This discussion includes a lot of analogies, diagrams, and screen shots. Finally, in most of the chapters you build a demonstration program. I don't think any of the demonstration programs are terribly sophisticated (they weren't meant to be). The example programs are designed to reinforce the topic that you are learning in that chapter. I show you how to build the example program in enough detail that a beginning Visual C++ programmer (if you can work through the Scribble tutorial in the Visual C++ documentation you're good to go) should have no problems following along. I think you will learn the most by building the example programs yourself, but if you don't want to go through the steps yourself you can download the demonstration programs from the FTP site for this book ftp://ftp.prenhall.com/pub/ptr/windows_technology.056/gordon.

Part 1: Laying the Foundation
In the first chapter, I define all the names in the COM namespace. Confused as to what COM, OLE, ActiveX, and the Windows DNA are? Chapter 1 defines these names and more. In Chapter 2 you learn a number of object-oriented concepts that are important pre-requisites to understanding COM. In particular, you learn what it means to be object-oriented and I define a class, an object, and an interface. The discussion of interfaces in this chapter is particularly important. In Chapter 3 I define the notion of a software bus and use it to explain some of the intricacies of COM: GUIDs, the IUnknown interface, Type libraries, Marshaling, and how COM uses the registry. In Chapter 4 you build your first COM class in an in-process server. You do this "from scratch" without the help of any wizards. You also build a COM client application. In Chapter 5 you learn how to build a COM server much more easily using the Active Template Library (ATL) and the ATL Object Wizard. All of the work that you do from Chapter 5 on uses ATL and/or Visual Basic.

Part 2: Digging Deeper
In Chapter 6 you learn how to build an out-of-process server. In Chapter 7 you learn about Automation. In Chapter 8 you learn about connection points. These 8 chapters are the pure COM material in this book. In Chapter 9 I discuss COM threading and Apartments. This chapter features some material (primarily Thread Neutral Apartments) that will be new to COM programmers who have not used COM+. In Chapter 10 I discuss DCOM and again in this chapter I discuss, briefly, some new topics like the Kerberos Security Support Provider.

Part 3: COM+
Chapter 11 begins our discussion of COM+. In Chapter 11 I discuss the COM+ architecture. You learn about Context's and Interception. You also learn how to configure a component using the Component Services Explorer. In Chapter 12 you learn about each of the Services that COM+ provides to components: fine-grained security, transactions, concurrency, store-and-forward method invocation (queued components), loosely-coupled events, load balancing, improved scalability thru just In Time activation and pooling of objects, and database connections. Chapter 13 is a big chapter in both size and significance. In this chapter you put it all together and build a 3-tiered, thin-client application using all the technologies in the Windows Distributed interNet Applications (DNA) Architecture: COM+, Active Server Pages, ADO, SQL Server 7, Visual C++, and Visual Basic. In Chapter 14 you use Queued Components to enhance your application. In this chapter you also learn how to use the Microsoft XML parser. Finally, in Chapter 15 you learn how to use COM+ Events.

The Intended Audience

You need to have at least a beginner's level knowledge of both Visual C++ and Windows Programming, in general, in order to understand this book. Also, the more you know about object oriented concepts, pointers, distributed processing, and multi-threading the easier time you will have learning COM. None of this knowledge is required to understand this book, as I do start from first principles. But trust me, the more you understand these concepts, the easier time you will have understanding COM, whether you learn from this book, another book, or a class.

Conventions used in this book

This book uses different features to help highlight key information. These features are discussed in the following sections.

Code Presentation
You will notice that there are three types of code listings. Some do not have a listing number, some have a listing number, and some have a listing number and numbered lines. Code that does not have a listing number is usually a short snippet that is included to illustrate a point.

Sidebars are used to present parenthetical information: information that is related to the topic at hand but does not flow directly with the main body of the chapter. In a few cases, I also use sidebars as a soapbox where I present information that is strictly my opinion, such as when I discuss my idea for a new COM naming scheme in Chapter 1. If you put a "by the way" or a "for your information" before each sidebar then you've got the idea.

Notes are used as small sidebars. Whenever I want to present parenthetical information that consists of only a sentence or two, I make it a note.

Tips are used to provide recommendations or to present information that can either save you time or prevent you from encountering minor problems.

Warnings are used to present information that is so important that I want it to stand out. I also use warnings to inform you of things that you must do to avoid serious problems. It is particularly important for you to pay heed to warnings that are associated with the example programs. In most cases, not following the warning will cause the example program not to work.

About the FTP Site

The FTP site for this book can be found at the following URL: ftp://ftp.prenhall.com/pub/ptr/windows_technology.056/gordon. The FTP site contains the errata for the book. It also contains the source code for all the example programs in the book. If you do not wish to build the example programs yourself, or you encounter problems building the examples, you can download the finished programs from the FTP site.


My name may be listed as the sole author of this book, but it took the work of a team of people to make this happen. Let me begin by thanking the people at Prentice Hall who were directly involved in the production of the book: my acquisitions editor, Tim Moore, my developmental editor, Jim Markham, and my technical reviewer, John Vacca. Special thanks to Jim for being so patient with me. Thanks also to Scott Suckling and the team at MetroVoice who did the final production work to turn my manuscript into the book you now hold in your hand. Next, I would like to thank all the people at UCLA Extension. It was through my work there that I was given the opportunity to write this book. Standout people I would like to mention are Terry Warner, Ben Stein, Carolyn Diliberto, Joseph Mueller, Donald Haushnect, and Robert Abnous. At Logicon's Advanced Technology Group I would like to thank everyone on the CAMPS project including Mark Flores, Rick Clough, Betty Hampikian, Curtis Enge, Marilyn Leatherwood, Theresa Millette, and Ward Keenan. I would like to especially thank everyone who worked for me when I was the technical lead on the Channels component including Bill Bulaich, Curt Miller, Sanjukta Chowdhurry, and Steve Caton. Others I would like to thank at Logicon include Roger Fuji, Vince Goshi, Steve Altstatt, Mike Twymann, and Steve Cooper. Many thanks to my lunch buddies at Logicon, Bill Bulaich and Paul Firnett. Since late August 1999 I have been working at a new company called FieldCentrix, http://www.fieldcentrix.com. This startup company is located in Irvine, California, and develops software for field service workers using the latest technology in wireless communications, rugged handheld PCs, and the Windows CE operating system. Those I would like to thank at FieldCentrix include Dave Key (the company founder), Dr. Albert Lin (who hired me), Paul Osterhoudt, Gaurav Jalota, Ashu Shende, Calvin Shen, Lap Tran, and Kevin Bates.

Many thanks to friends who have influenced me including: Dr. Quintus Jett, Dr. George Shaw, Dr. Shozo Koshigoe, Carlos Castellanos, and Ruel Nuqui. Next, I would like to thank my family. Kudos to my older brother Winston Gordon, Jr. When I was an Aerospace Engineering major at UCLA, he scoffed when I was learning FORTRAN-told me that C was the way to go. Eventually, I bought books on C and on C++. He started me on a journey that culminated in my writing this book. I would also like to thank my parents, Agatha and Winston Gordon, Sr. I can never repay you for all you've done for me so I say thank you. Other members of my family I would like to thank include Vera Littlejohn, Dr. Mary Marin, Alma Horper, Kaylah Marin, Mikalynn Todd, Amber Saucedo, and Sharine Dinwiddie. Finally, and most importantly, I would like to thank the two special women in my life: my wife Tamber Lynn and my daughter Bria Almarie. Thank you both for all the love and support you gave me and continue to give me, before, during, and after this book was written. You sacrificed so much to make this a reality. Thank you, Tamber, for encouraging me when I was ready to give up this project and I'm sorry for all the times I wasn't at my best while writing this book. Bria, forgive me for the times I couldn't play with you while I was writing this book. I hope one day you will understand that I did it to help build a better life for us. To anyone I forgot, my apologies and heartfelt thanks.


Download the Index file related to this title.


Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information

To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.


Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.


If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information

Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.


This site is not directed to children under the age of 13.


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information

If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information

Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents

California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure

Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact

Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice

We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020