Intro to COM - PowerPoint PPT Presentation

1 / 17
About This Presentation
Title:

Intro to COM

Description:

Intro to COM What is it and how do I use it? Objectives Teach the fundamentals of COM. Understand the reason for using it. Learn to make a simple in-process server. – PowerPoint PPT presentation

Number of Views:62
Avg rating:3.0/5.0
Slides: 18
Provided by: illi54
Category:
Tags: com | intro

less

Transcript and Presenter's Notes

Title: Intro to COM


1
Intro to COM
  • What is it and how do I use it?

2
Objectives
  • Teach the fundamentals of COM.
  • Understand the reason for using it.
  • Learn to make a simple in-process server.

3
COM Defined
  • COM (Component Object Model) and DCOM
    (Distributed COM)
  • are a set of binary and network standards for the
    modeling of objects and their communications.

4
What does it do?
  • It allows for Plug and Play software.
  • Helps to create distributed systems transparently.

5
Why should you learn COM?
  • Flexibility can be used from and written in all
    popular languages.
  • Saves tremendous time (after the initial learning
    curve)
  • Use of existing objects
  • Object Reuse C tried to address this issue,
    but just made it easy to reuse source code.
  • So you can use DCOM.

6
Why should you learn COM?
  • Rapid Application Development
  • Seamless application updates
  • Build great apps without reinventing the wheel
  • Interface different systems with ease

7
Component Hierarchy
  • Components are made up of objects
  • Objects are made up of interfaces
  • Interfaces are made up of member functions

8
What makes an object?
  • Objects support object-oriented principles
  • encapsulation
  • polymorphism
  • inheritance?
  • Conceptual in nature
  • Known only through interfaces

Object
9
What makes an object?
  • Clients can interact with any object without
  • knowing which object with which it interacts

Object 1
Client
Object 2
10
The Specifics
11
Identifiers
  • GUID (globally unique identifiers)
  • are stored in 16-byte (128 bit) structures
  • CLSID (class identifier GUID)
  • IID (interface identifier GUID)

IUnknown
  • QueryInterface
  • Returns a pointer to requested Interface
  • AddRef
  • Increases the RefCount
  • Release
  • Decreases the RefCount

12
Interfaces
  • An interface is a set of similar methods
  • Analogous to a C class
  • Binary level, not source code level
  • Indentified by an Interface Identifier (IID)

interface ISquirrel IUnknown HRESULT
EatNuts() HRESULT ClimbTree() HRESULT
RunAway()
13
IUnknown
  • Base interface
  • Polymorhic to all other interfaces
  • Implements reference counting
  • All other interfaces are retrieved through
    IUnknown

interface IUnknown ULONG AddRef() ULONG
Release() HRESULT QueryInterface(REFIID iid,
void ppObject)
14
Accessing Objects
STDAPI CoCreateInstance( REFCLSID
rlcsid, LPUNKNOWN pUnkOuter, DWORD
dwClsContext, REFIID riid, LPVOID ppv )
  • CoCreateInstance
  • Based on a class ID (CLSID)
  • Specify requested interface
  • Object can be anywhere

15
Where do components live?
  • In-Process servers (.dll)
  • Out-of-Process servers (.exe)
  • Remote servers (.exe)
  • ActiveX (.ocx)

16
Uses
  • ActiveX
  • DCOM
  • DirectX
  • Automation
  • OLE
  • etc.

17
Recommended Reading
  • The definitive beginners guide to COM
  • Inside COM by Dale Rogerson
  • A great online tutorial that summarizes much of
    Inside COM
  • http//beta.develop.com/comtutorial
  • For the complete history and theory
  • Inside OLE by Kraig Brockschmidt
Write a Comment
User Comments (0)
About PowerShow.com