Home > Store

Essential COM

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

Essential COM

Book

  • Sorry, this book is no longer in print.
Not for Sale

Description

  • Copyright 1998
  • Dimensions: 7-3/8" x 9-1/4"
  • Pages: 464
  • Edition: 1st
  • Book
  • ISBN-10: 0-201-63446-5
  • ISBN-13: 978-0-201-63446-4

"Don Box makes it possible for mere mortals to join the COM cognoscenti. If youire a C++ COM programmer, buy this book." -David Chappell, Principal, Chappell & Associates and author of  Understanding ActiveX and OLE

Written by a leading COM authority, this unique book reveals the essence of COM, helping developers to truly understand the why, not just the how, of COM. Understanding the motivation for the design of COM and its distributed aspects is critical for developers who wish to go beyond simplistic applications of COM and become truly effective COM programmers. As the COM programming model continues to evolve, such insight also becomes essential to remaining current with extensions, such as Microsoft Transaction Server and COM+. By showing you why Distributed COM works as it does, Don Box enables you to apply the model creatively and effectively to everyday programming problems.

This book examines COM from the perspective of a C++ developer, offering a familiar frame of reference to ease you into the topic. You will also find comprehensive coverage of the core concepts of Distributed COM (interfaces, classes, apartments, and applications), including detailed descriptions of COM theory, the C++ language mapping, COM IDL (Interface Definition Language), the remoting architecture, IUnknown, monikers, threads, marshalers, security, and more. In addition, the book offers a thorough explanation of COMis basic vocabulary, provides a complete Distributed COM application to illustrate programming techniques, and includes the authoris tested library of COM utility code.



0201634465B04062001

Downloads

Source Code

Source Code and Online Resources

Source Code Files:

aptsur.zip
giplip.zip
hosthook.zip
meowmoniker.zip
COMCHAT.zip

Sample Content

Downloadable Sample Chapter

Click below for Sample Chapter related to this title:
chap01.pdf

Table of Contents


Foreword by Charlie Kindel.
Foreword by Grady Booch.
Preface.
1. COM as a Better C++.

Software Distribution and C++.

Dynamic Linking and C++.

C++ and Portability.

Encapsulation and C++.

Separating Interface from Implementation.

Abstract Bases as Binary Interfaces.

Runtime Polymorphism.

Object Extensibility.

Resource Management.

Where Are We?


2. Interfaces.

Interfaces and Implementations Revisited.

IDL.

Methods and Results.

Interfaces and IDL.

Iunknown.

Resource Management and Iunknown.

Type Coercion and Iunknown.

Implementing Iunknown.

Using COM Interface Pointers.

Optimizing QueryInterface.

Data Types.

Attributes and Properties.

Exceptions.

Where Are We?


3. Classes.

Interface and Implementation.

Class Objects.

Activation.

Using the SCM.

Classes and Servers.

Generalizations.

Optimizations.

Interface and Implementation Again.

Monikers and Composition.

Monikers and Persistence.

Server Lifetime.

Classes and IDL.

Class Emulation.

Competent Categories.

Where Are We?


4. Objects.

IUnknown Revisited.

QueryInterface Is Symmetric.

QueryInterface Is Transitive.

QueryInterface Is Reflexive.

Objects Have Static Type.

QueryInterface and Iunknown.

Uniqueness and Identity.

Multiple Interfaces and Method Names.

Dynamic Composition.

Binary Composition.

Containment.

Where Are We?


5. Apartments.

Interface and Implementation Revisited.

Objects, Interfaces, and Apartments.

Cross-Apartment Access.

In-Process Marshaling Helpers.

Standard Marshaling Architecture.

Lifecycle Managing and Marshaling.

Custom Marshaling.

The Free Threaded Marshaler.

Where Are We?


6. Applications.

In-Process Activation Pitfalls.

Activation and the SCM.

Server Lifetime Revisited.

Application Ids.

COM and Security.

Programmatic Security.

Access Control.

Token Management.

Where Are We?


7. Miscellanea.

Pointer Basics.

Pointers and Memory.

Arrays.

Flow Control.

Dynamic versus Static Invocation.

Bidirectional Interface Contracts.

Aliasing in IDL.

Asynchronous Methods.

Where Are We?


Appendix A. The Evolution of Objects.
Appendix B. Selected Code Fragments.
Index. 0201634465T04062001

Preface

My work is done.

I can finally rest, knowing that I have finally put into writing what many have termed the rich oral history of COM. This book reflects the evolution of my own understanding of this rogue technology that Microsoft was kind enough to reveal to the programming world in 1993. While I did not attend the original OLE Professional Developer's Conference, I still feel as if I have been doing COM forever. After almost four years of working with COM, I can barely remember the pre-COM era of computing. I can, however, vividly remember my own painful trek across the COM landscape in early 1994.

It took me roughly six months before I felt I understood anything about COM. During this initial six-month period of working with COM, I could successfully write COM programs and almost explain why they worked. However, I had no organic understanding of why the COM programming model was the way it was. Fortunately, one day (August 8, 1994, roughly six months after buying the book Inside OLE2), I had an intense epiphany and at once COM seemed obvious to me. This by no means meant that I understood every COM interface and API function, but rather, that I understood the primary motivating factors behind COM. From this, it became clear how to apply the programming model to everyday programming problems. Many other developers have related similar experiences to me. As I write this preface three Augusts after the fact, developers still must go through this six-month waiting period prior to becoming productive members of COM society. I would like to think that this book might shorten that time period, but I make no promises.

As this book emphasizes, COM is more a programming discipline than a technology. To this end, I have attempted to not bludgeon the reader with detailed descriptions of each parameter to each method from each interface. Rather, I have tried to distill the essence of what COM is really about, leaving the SDK documentation to fill in the gaps left behind by each chapter. Wherever possible, I have attempted to address the underlying tensions that motivate a particular aspect of COM rather than provide detailed examples of how to apply each interface and API function to a contrived example program. My own experience has shown that once the why is understood, the how follows fairly naturally. Conversely, simply knowing the how rarely provides adequate insight to extrapolate beyond the documentation. This insight is critical if one hopes to keep up with the programming model's continual evolution.

COM is an extremely flexible substrate for building distributed object-oriented systems. To take advantage of COM's flexibility, one must often think outside the constraints of the SDK documentation, articles or books. My personal recommendation is to assume that anything you read (including this book) may be incorrect or woefully out of date and instead form your own personal understanding of the programming model. The surest way to understand the programming model is to focus on mastering the basic vocabulary of COM. This can only be accomplished through writing COM programs and analyzing why those programs work the way they work. Reading books, articles and documentation can help, but ultimately, dedicating the time to contemplate the four core concepts of COM (interfaces, classes, apartments and security) can only enhance your effectiveness as a COM developer.

To help the reader focus on these core concepts, I have tried to include as much code as possible without explicitly providing elaborate implementations for the reader to simply copy into their own source code. To ensure that COM programming techniques are also presented in context, Appendix B contains one complete COM application that is an example of many of the concepts discussed throughout the book. Additionally, Appendix B contains a library of COM utility code that I have found useful in my own development. Some parts of this library are discussed in the book in detail, but the entire library is included as a demonstration of how to architect de facto C++ implementations. Also note that much of the code that appears in each chapter uses the C runtime library macro assert to emphasize that certain pre- or post-conditions must be met. In production code, many of these assert statements should be replaced with somewhat more forgiving error handling code.

One downside of published books is that they are often obsolete by the time they arrive at the local bookstore. This book is no different. In particular, the pending release of COM+ and Windows NT 5.0 will certainly render various aspects of this book incorrect or at least incomplete. I have tried to anticipate the evolution of the model imposed by the release of Windows NT 5.0, however, at the time of this writing, Windows NT 5.0 has not yet entered its public beta cycle and all information is subject to change. COM+ promises to evolve the model even further, however, it was impossible to include COM+ coverage and still deliver my manuscript this year. I highly encourage you to investigate both Windows NT 5.0 and COM+ when they become available.

One rather painful decision I had to make was how to address the various commercial libraries used to implement COM components in C++. After observing the common questions that appear on various Internet newsgroups, I elected to ignore ATL (and MFC) and instead focus on the bread-and-butter topics of COM that every developer must master irrespective of the library used. More and more developers are generating ATL spaghetti and wondering why things don't work. I firmly believe one cannot learn COM by programming in ATL or MFC. This does not mean that ATL and MFC are not useful tools for developing COM components. It simply means that they are not suited to demonstrating or learning COM programming concepts and techniques. This makes ATL inappropriate for a book focused on the COM programming model. Fortunately, most developers find that once COM is understood, the basics of ATL can be mastered in short order.

Finally, the quotes that begin each chapter are a chance for me to write whatever I felt like for a small section of the book. In an effort to keep my writing as direct as possible, I restricted my wild off-topic stories to no more than 15 lines of C++ code per chapter. Usually, the code/quote represents the pre-COM approach to a problem or concept presented in the chapter. I leave it as an exercise for the reader to deconstruct my state of mind when writing a particular chapter based on these hints.

Acknowledgements

Writing a book is incredibly hard, at least it was for me. Two people who I know for certain suffered more than I did were my patient wife Barbara and my tolerant son Max (who prefers COM to other object models despite his youth). To both of you, thanks for tolerating my absence and generally cranky disposition while I tried to write. Fortunately, my freshly-instantiated daughter Evan was born after the bulk of this book was written and has had a fairly present and pleasant father. A related thanks goes out to all the staffers at DevelopMentor who had to cover for me when I "went dark" to crank out chapters.

A lot of my early thinking about distributed systems was formed working for Tatsuya Suda at UC Irvine in the early 1990's. Tatsuya taught me how to write, how to read, and how to deal with unruly train passengers in Tokyo. Thanks and sorry.

Thanks to my old office-mate Doug Schmidt for introducing me to Stan Lippman at the C++ Report. Despite Stan's rousing rejection of my first article, I first got my name in lights thanks to you two. Thanks to Mike Hendrickson and Alan Feuer at Addison Wesley for getting this project started. Thanks to Ben Ryan and John Waite for being patient. Thanks to the folks at Microsoft Systems Journal who tolerated my late submissions during the production of this book. In particular, thanks to Joanne Steinhart, Gretchen Bilson, Dave Edson, Joe Flanigen, Eric Maffei, Michael Longacre, Joshua Trupin, Laura Euler, and Joan Levinson. I promise never to be late again.

Thanks to David Chappell for writing the finest book on COM available. I heartily recommend that everyone buy a copy and read it at least twice. Thanks to the CORBA and Java partisans and zealots who have engaged me in flame-wars on various Usenet newsgroups over the years. Your constant vigilance has made my own understanding of COM infinitely better. Despite the fact that I still feel many of your arguments are specious and somewhat Martian, I respect your desire to survive.

Several people at Microsoft proper have been very helpful to me over the years and either directly or indirectly helped me write this book. Sara Williams was the first COM person from Microsoft I had ever met. Right after explaining that she didn't know Bill all that well, she introduced me to Gretchen Bilson and Eric Maffei at Microsoft Systems Journal as consolation. Sara has always been a great "Box Evangelist" within the big house and I am forever grateful. Charlie Kindel wrote the nice forward to my book despite his heavy schedule and exceedingly regular trips to the barber. Nat Brown was the first person to show me apartments and has irrevocably polluted my vocabulary with the word "schwing." Kraig Brockschmidt explained to me that one particular aspect of COM that looks incredibly elegant was actually a grotesque last-minute hack. Dave Reed introduced me to Viper and listens to my clams each time I visit Redmond. Pat Helland spent the entire week of TechEd 97 twisting my brain and forcing me to reexamine most of my basic assumptions about COM. Scott Robinson, Andreas Luther, Markus Horstmann, Mary Kirtland, Rebecca Norlander, and Greg Hope have been great at keeping me out of the dark. Ted Hase helped me spread the word. Rick Hill and Alex Armanasu did a great job watching my back on the technical front. Other Microsoft people who have influenced my work through their own include Tony Williams, Bob Atkinson, Craig Whittenberg, Crispin Goswell, Paul Leach, David Kays, Jim Springfield, Christian Beaumont, Mario Goertzel, and Michael Montague.

The DCOM mail reflector has been a great source of inspiration and ideas for this book. Special thanks go to the following DCOM-listers: the infamous Mark Ryland, COM wunderkind Mike Nelson, Keith Brown, Tim Ewald, Chris Sells, Saji Abraham, Henk De Koenig, Steve Robinson, Anton von Stratten and Randy Puttick. The story in this book has been greatly influenced by my teaching COM at DevelopMentor for the past several years. The story has been shaped as much by the students as it has by my fellow instructors. While I wish I could thank every student personally (Addison Wesley has limited my preface to less than 20 pages), I can thank the current set of DevelopMentor-ites who have helped me refine my own understanding by teaching our Essential COM course and providing invaluable feedback: Ron Sumida, Fritz Onion, Scott Butler, Owen Tallman, George Shepherd, Ted Pattison, Keith Brown, Tim Ewald and Chris Sells. Thanks guys! Thanks also to Mike Abercrombie of DevelopMentor for creating an environment where personal growth isn't stiffled by commerce.

This book would have been released considerably earlier had it not been for Terry Kennedy and friends at Software AG. Terry was nice enough to invite me to help with the DCOM/UNIX effort in Germany during the sabbatical I had initially carved out to write the book. While this book is a year late because I couldn't say no to Terry (this is my fault, not Terry's), I think that the book is infinitely better due to the time I spent working on the project. In particular, I gained many insights working with Harald Stiehl, Winnie Froehlich, Volker Denkhaus, Deitmar Gaertner, Jeff Lee, Deiter Kesler, Martin Koch, Blauer Afe, and the notorious Thomas Vogler. Finally, thanks to Shah Jehan and the Coca-Cola Corporation for fueling this effort by respectively producing the most delicious Indian food and soft drinks available.

Don Box
Redondo Beach, CA
August 1997
http://www.develop.com/dbox



0201634465P04062001

Updates

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.

Overview


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.

Surveys

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.

Newsletters

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.

Security


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

Children


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

Marketing


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.

Choice/Opt-out


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.

Links


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