Mastering COM Development Using Visual C++
Class #1012Table of Contents
Introduction
At Course Completion
Microsoft Certified Professional Exams
Prerequisites
Course Materials and Software
Course Outline
This CD-based course will teach developers who use the Microsoft® Visual C++®
development system how to create component object model (COM) objects using Visual C++ and
the Active Template Library (ATL).
Return to top
At the end of the course, students will be able to:
- Use COM to address component-based software development issues.
- Build clients of COM objects.
- Build COM object servers.
- Create ActiveX controls.
- Use Visual C++ extensions to create clients of COM objects.
- Build COM objects that reuse existing COM objects.
- Add events to COM objects and clients.
- Create COM objects with dual interfaces.
Return to top
This course will help the student prepare for the following Microsoft Certified
Professional exam(s):
Return to top
Before beginning this course, students should be able to:
- Describe and use the following C++ fundamentals:
- Constructors and destructors
- Virtual functions
- Conversion functions
- Function overloading
- Operator overloading
- Accessors
- Single and multiple inheritance
- Templates
- Use the Microsoft Windows® operating system and the Visual Studio development
system
The course materials, lectures, and lab exercises are in English. To benefit fully
from our instruction, students need an understanding of the English language and
completion of the prerequisites.
Return to top
The course workbook and lab book and student CD are the student's to keep.
The following software will be provided for use in the classroom:
- Microsoft Visual C++ Professional Edition
Return to top
Day 1
Chapter 1: Introduction to COM
Topic:
Issues surrounding software development that the Component Object Model attempts to
address
Skills:
Students will be able to:
- List and explain the problems that confront component software developers today.
- List and explain attempted solutions to traditional component software development.
- Explain the drawbacks of various solutions to component software development.
- List the solutions that COM provides for component software development problems.
Chapter 2: Creating a Client of a COM Object
Topic:
Creating a COM object client using C++
Labs:
Registering a COM object
Creating a client of a COM object
Skills:
Students will be able to:
- Explain how COM uses strings.
- Write code to initialize and uninitialize COM services.
- Explain CLSIDs, ProgIDs, their use in the registry, and how COM system services and
client applications use them.
- Write code that creates and uses a simple COM object.
Chapter 3: Creating a COM Object
Topics:
Fundamentals of COM
Creating a simple COM object
Labs:
Creating a simple COM object
Writing code that creates and uses a simple COM object
Coding the WinMain function for an out-of-process COM object server
Writing a registry file
Skills:
Students will be able to:
- Explain the concept of immutability in relation to interfaces.
- Describe the purpose of the IUnknown interface.
- List and describe the three methods of the IUnknown interface.
- Explain reference counting and its implications.
- Explain, generate, and use a globally unique identifier (GUID).
- Derive a C++ class from an interface and implement all required methods.
- Create a class factory for a COM object.
- Explain the difference between a COM object and a COM object server.
- Write code for the WinMain function of a simple COM object.
- Register a COM object.
- Add code to the registry functions for COM to support self-registration.
- Create a registry (.reg) file and manually register an object.
Chapter 4: Implementing Multiple Interfaces
Topic:
Techniques to implement COM objects with multiple interfaces
Labs:
Adding an interface to an object by using multiple inheritance
Modifying IUnknown::QueryInterface to reflect added interfaces
Calling QueryInterface in a client application to obtain additional interfaces
Skills:
Students will be able to:
- Use multiple inheritance to add a second interface manually to a simple COM object.
- Add code for a second interface to the QueryInterface method.
- Create a client that will use a COM object that has multiple interfaces.
- Explain the VTBL layout of a COM object that supports multiple inheritance.
Day 2
Chapter 5: Introduction to the Active Template Library
Topics:
Structure, primary features, and basic use of the Active Template Library in creating
COM components
Using the Visual C++ extensions to create a client of a COM object
Labs:
Using ATL COM AppWizard to create the shell for a COM object
Using ATL Object Wizard to add a simple COM object to the ATL project
Manually adding existing interfaces to the COM object server
Using C++ extensions and smart pointers to create a COM object client application
Skills:
Students will be able to:
- Use ATL COM AppWizard to create a COM object server.
- Use ATL Object Wizard to add a simple COM object with a custom interface to an ATL COM
project.
- Use Visual C++ extensions to facilitate writing a COM client application.
- Manually add an interface to an ATL COM project.
- Describe the following items in an ATL COM project: COM map, Object map, CComModule,
CComObjectRoot, and CComCoClass.
Chapter 6: Automation
Topics:
Creating COM components that support automation
Using IDispatch to implement automation
Dispinterfaces
Early and late binding
Interface Definition Language (IDL) basics
Labs:
Using OLE/COM Object Viewer to locate and browse type libraries
Defining properties and methods in IDL for a dispinterface
Using the MIDL compiler to compile IDL into type libraries
Skills:
Students will be able to:
- Add properties and methods to a COM object.
- Identify which data types can be passed with automation.
- Create a type library.
Day 3
Chapter 7: Dual Interfaces
Topic:
Improving efficiency of automation interfaces by turning them into dual interfaces
Lab:
Creating an ActiveX technology component that supports automation using the ATL
wizards
Skills:
Students will be able to:
- Explain the difference between dispinterfaces, custom interfaces, and dual interfaces.
- Define a dual interface, with its properties and methods, in Interface Definition
Language.
- Explain the benefits and limitations of dual interfaces.
- Create a dual interface with the ATL.
Chapter 8: Adding Events
Topic:
Using ATL classes to add events to a COM object and to an MFC client of the COM object
Labs:
Creating a COM object that fires an event
Creating a client that receives an event fired by a COM object
Skills:
Students will be able to:
- Add event firing to an ATL-generated COM object.
- Add an event-handling interface to a MFC-built COM client.
- Explain how events work in COM from a server and client perspective.
Day 4
Chapter 9: Creating an ActiveX Control
Topics:
Creating an ActiveX control using ATL
Basic parts of ATL used to make an ActiveX control work, such as the message map and the
OnPaint method
Different property types, such as ambient properties and stock properties
Creating a property page
Labs:
Creating an ActiveX control with ATL Object Wizard
Adding a stock property, custom property, custom method, and custom event
Reusing an existing window class
Skills:
Students will be able to:
- Create a control with ATL.
- Modify the OnDraw method to draw graphical output for a control.
- Create a property page.
- Read ambient properties.
Chapter 10: Object Reuse in COM
Topics:
Reusing objects in COM through containment and aggregation
Differences between inheritance and aggregation
Differences between implementation inheritance and interface inheritance
Reuse through COM containment
Reuse through COM aggregation
Creating an aggregated object using ATL
Labs:
Using ATL to create a COM object that can be aggregated
Using ATL to create a COM object that aggregates another COM object
Skills:
Students will be able to:
- Explain the difference between implementation inheritance and interface inheritance.
- Explain the difference between COM containment and COM aggregation.
- Create an aggregated object with ATL.
Chapter 11: Custom Interfaces
Topic:
Creating and marshaling custom interfaces
Creating a proxy/stub dynamic-link library (DLL) to marshal a custom interface
How the standard marshaling architecture works in COM
Labs:
Creating a custom interface with ATL
Creating a proxy/stub DLL for a custom interface
Using the default allocator in COM to allocate and free memory dynamically
Writing IDL syntax to pass arrays efficiently
Skills:
Students will be able to:
- Explain why custom interfaces are necessary.
- Create a custom interface in ATL that works across process boundaries.
- Describe the process used by a proxy/ stub DLL to marshal data types.
- Explain why marshaling creates memory management and distribution issues.
- Create a proxy/stub DLL using ATL.
Day 5
Chapter 12: Threading Models
Topics:
COM threading models
How mixed threading models with in-process and out-of-process clients and servers can
cause marshaling issues
Labs:
Identify which threading model combinations are most efficient, and which are the least
efficient
Identify which threads can be called from a client to a server with different threading
model scenarios
Skills:
Students will be able to:
- Explain the differences between single-threaded applications, single-threaded apartment
models, and multithreaded apartment models.
- Explain how mixing threading models with in-process and out-of-process servers can cause
marshaling issues.
- Identify the registry keys for threading models.
Chapter 13: Collections
Topics:
Creating and using enumerator components to create an object model
Creating an object model consisting of both public and private objects via COM services or
some internal creation method
Labs:
Creating a collection that contains COM objects
Creating a client that uses a collection
Skills:
Students will be able to:
- Add single and multilevel property collections to an ATL-built COM object.
- Write client-side code in C++ for iterating over collections.
- Create and use enumerator objects.
Return to top
|