COM Programming with C++ - A 5 Day Course
Synopsis
Microsoft's Component Object Model (COM) has transformed Windows into an object-oriented operating system. COM specifies an object model in which developers define services in terms of interfaces. Compliant Windows objects can then interoperate via these interfaces. COM changes the way Windows applications are structured and written, and opens up many more possibilities. This course is an essential introduction for Windows architects and analyst/programmers who need a wide appreciation of how COM enables client/server and object-oriented solutions, by giving the delegate a thorough grounding in the theory of COM, as well as examples of its use.
This course focuses on developing COM servers initially in raw C++ and then taking advantage of the Active Template Library (ATL) to simplify creation and use of COM servers. The course concludes with an introduction to Microsoft's range of Component Services in COM+.
The practical sessions build on the information given in the lectures. The sample applications that you will build during the week will show how to use the COM features presented. You will also receive additional support material, including example and demonstration software sources. Examples and practical exercises use Microsoft Visual Studio 6 under Windows 2000.
Course Objectives
After completing this course, students will be able to:
- Understand why COM is needed
- List the main features of the Component Object Model (COM)
- Implement a COM server and client
- Use ATL to simplify COM development
- Generate and handle events with connectable objects
- Understand the issues with distributing COM functionality
- Describe the core facilities of COM+
Suitable for
Experienced C++ programmers who wish to develop COM-based applications.
Prerequisites
- Six months C++ programming and at least three months Windows programming experience is essential. Familiarity with the Microsoft Visual Studio and Microsoft Visual C++. Prior attendance of one of our Windows Programming courses is also preferred.
Publicly scheduled dates, locations, and prices
A schedule of dates for this course is not currently available. Please call 0800 651 0338 or use our contact form to enquire about places and availability.
Contents:
Component Architecture
- Components and component based systems
- Issues in code re-use
- Separating interface from implementation
- Interfaces and polymorphism
- Binary encapsulation
- Virtual function tables
- Instance management
- Implementing multiple interfaces
- Resource management and reference counting
COM Fundamentals: Writing a COM Client
- Using COM objects from C++
- Using COM objects from other clients
- GUIDs
- HRESULTs
- Using class objects
- Introducing IUnknown
- Using AddRef(), Release() and QueryInterface()
COM Fundamentals: Writing a COM Server
- Implementing a COM object in C++
- Implementing IUnknown
- Implementing a class object and IClassFactory
- Supporting multiple interfaces
- Registering a COM server
Introduction to IDL
- Defining an interface
- Basic keywords
- IDL types
- Passing parameters in and out
- Properties
- Interface inheritance
- Importing definitions
- Type libraries and the library keyword
- Using the MIDL compiler
Exploiting The Active Template Library (ATL)
- C++ Templates
- Features and benefits
- CComModule
- Interface and object maps
- Implementing IUnknown and where your class fits
- Registry scripts
- Using the ATL wizards in Visual C++
Automation
- Automation for late binding
- IDispatch, dispids and dispinterfaces
- Dual interfaces
- Automation-compatible types
- VARIANTs, BSTRs and SAFEARRAYs
- Properties
- ATL support for Automation
Connectable Objects
- Events and callbacks
- Connection points
- IConnectionPoint and IConnectionPointContainer
- ATL support for connection points
Threads and Apartments
- COM threading issues
- Protecting global and instance data
- Single threaded apartments
- Multi threaded apartments
- Marshaling requirements
- Apartment support in ATL
Out-of-Process Servers and Distributed COM
- Issues with going cross-process
- Marshaling with proxies and stubs
- Writing EXE Servers
- Remoting COM Servers with DCOM
- Configuring servers with DCOMCNFG
- Overview of security and threading issues
Introduction to COM+ Component Services
- What is COM+?
- Transactions in COM+
- Object pooling
- JIT Activation
- COM+ Loosely coupled events
- Queued components
The Way Ahead
- Attributed C++
- COM, COM+ and interoperation with .NET
