Introduction to COM and ActiveX Controls. What is an object? In the Fayad sense of the word.

Slides:



Advertisements
Similar presentations
What is a Computer Program? For a computer to be able to do anything (multiply, play a song, run a word processor), it must be given the instructions.
Advertisements

Message Passing Vs Distributed Objects
Microsoft® Access® 2010 Training
COM vs. CORBA.
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.
28/1/2001 Seminar in Databases in the Internet Environment Introduction to J ava S erver P ages technology by Naomi Chen.
1 COM/DCOM n Part of Project Presentation (Concept Outline)
Why COM and.Net? Jim Fawcett CSE775 – Distributed Objects Spring 2005.
Object-oriented Programming Concepts
Object Based Operating Systems1 Learning Objectives Object Orientation and its benefits Controversy over object based operating systems Object based operating.
Reuse Activities Selecting Design Patterns and Components
C++ fundamentals.
UNIT-V The MVC architecture and Struts Framework.
A Free sample background from © 2001 By Default!Slide 1.NET Overview BY: Pinkesh Desai.
1 1 1 Introduction to Java. 2 History of Java Java – Originally for intelligent consumer-electronic devices – Then used for creating Web pages with dynamic.
Intro to COM What is it and what can it do for me?
DCOM Technology. What is DCOM? DCOM is just COM with a longer wire DCOM is just COM with a longer wire DCOM extends COM to support communication among.
DCOM Technology Şevket Duran Haşim Sak.
1 Modular Software/ Component Software 2 Modular Software Code developed in modules. Modules can then be linked together to produce finished product/program.
Visual Basic: An Object Oriented Approach 12 – Creating and using ActiveX objects.
CSCI 224 Introduction to Java Programming. Course Objectives  Learn the Java programming language: Syntax, Idioms Patterns, Styles  Become comfortable.
Beyond DHTML So far we have seen and used: CGI programs (using Perl ) and SSI on server side Java Script, VB Script, CSS and DOM on client side. For some.
CSC Proprietary 9/11/2015 2:16:16 AM 008_P2_CSC_white 1.
Lesley Bross, August 29, 2010 ArcGIS 10 add-in glossary.
MT311 Java Application Development and Programming Languages Li Tak Sing( 李德成 )
UNIVERSITI TENAGA NASIONAL “Generates Professionals” CHAPTER 4 : Part 2 INTRODUCTION TO SOFTWARE DEVELOPMENT: PROGRAMMING & LANGUAGES.
Obsydian OLE Automation Ranjit Sahota Chief Architect Obsydian Development Ranjit Sahota Chief Architect Obsydian Development.
COM vs. CORBA Computer Science at Azusa Pacific University September 19, 2015 Azusa Pacific University, Azusa, CA 91702, Tel: (800) Department.
©Ian Sommerville 2000 Software Engineering, 6th edition. Slide 1 Component-based development l Building software from reusable components l Objectives.
Tutorial 121 Creating a New Web Forms Page You will find that creating Web Forms is similar to creating traditional Windows applications in Visual Basic.
9 Chapter Nine Compiled Web Server Programs. 9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic.
‘Tirgul’ # 7 Enterprise Development Using Visual Basic 6.0 Autumn 2002 Tirgul #7.
COM/DCOM Implementation Basics of: Object creation and access Object Reuse Interface referencing.
COM and DCOM CS 562 February 27, Motivation Data Analyzer Resource Monitor int compute (…) { } int compute (…) { } Data Analyzer int compute (…)
Introduction to COM and DCOM Organizational Communications and Technologies Prithvi N. Rao H. John Heinz III School of Public Policy and Management Carnegie.
COMCOM omponent bject odel After this presentation, you will: Be Able To: Conceptual understanding of COM How it works, What it’s used for Decode Acronyms.
A COM implementation of the KSpace A ‘Knowledge Space prototype’ by Santhosh CST
1 Pertemuan 26 Bahasa-bahasa Pemrograman (Lanjutan) Matakuliah: T0604-Pengantar Teknologi Informasi Tahun: 2008 Versi: 2.0/0.0 Williams, B.K, Stacy C.
Patterns in programming 1. What are patterns? “A design pattern is a general, reusable solution to a commonly occurring problem in software. A design.
Java Applets. 2 Introduction to Java Applet Programs  Applications are stand alone programs executed with Java interpreter executed with Java interpreter.
CSCI-383 Object-Oriented Programming & Design Lecture 13.
1 CSC204 – Programming I Lecture 2 Intro to OOP with Java.
Just as there are many human languages, there are many computer programming languages that can be used to develop software. Some are named after people,
Grid Computing Research Lab SUNY Binghamton 1 XCAT-C++: A High Performance Distributed CCA Framework Madhu Govindaraju.
Java Applets. 2 Introduction to Java Applet Programs Applications are ___________________ programs –executed with Java interpreter Applet is a small program.
Module 4 Part 2 Introduction To Software Development : Programming & Languages Introduction To Software Development : Programming & Languages.
Distribution and components. 2 What is the problem? Enterprise computing is Large scale & complex: It supports large scale and complex organisations Spanning.
Chapter 6 Introduction to Defining Classes. Objectives: Design and implement a simple class from user requirements. Organize a program in terms of a view.
Learners Support Publications Object Oriented Programming.
GAM666 – Introduction To Game Programming ● DirectX is implemented as a collection of COM objects ● To use a DirectX program, the user must have the correct.
Seminarium on Component-based Software Engineering Feraaz Imami LIACS – Leiden University Fall 2005 Component Object Model (COM)
CSI 3125, Preliminaries, page 1 SERVLET. CSI 3125, Preliminaries, page 2 SERVLET A servlet is a server-side software program, written in Java code, that.
1 Distributed Processing Framework Behind the scenes.
Plug-In Architecture Pattern. Problem The functionality of a system needs to be extended after the software is shipped The set of possible post-shipment.
Component Object Model(COM)
Writing simple Java Web Services using Eclipse
Microsoft’s Distributed Component Object Model (DCOM)
Distribution and components
Out-of-Process Components
PHP / MySQL Introduction
Java Applets.
Out-of-Process Components
Active Template Library
Presented By Justas Raslanas
Chapter 8 - Design Strategies
Lecture 7 ATL and Out-of-Process Components
Jim Fawcett CSE775 – Distributed Objects Spring 2007
Plug-In Architecture Pattern
CORBA and COM TIP Two practical techniques for object composition
Jim Fawcett CSE687 – Object Oriented Design Spring 2015
Presentation transcript:

Introduction to COM and ActiveX Controls

What is an object? In the Fayad sense of the word

Object Oriented Themes (Object Oriented Modeling and Design, Prentice-Hall, 1991) Abstraction: what should an object do, not how an object is implemented Encapsulation: what should be accessible to other objects and what shouldn’t Couple behavior with data: object contains data and operations to perform on that data Sharing: code reuse through aggregation and inheritance Does a car known what kind wheel it has?

Object oriented themes and C++ We create C++ class to – Encapsulate (class)ifications of data – Abstract our client code from operations on classifications of data – Build classifications of data that are not specific to any application but instead are generic and therefore reusable. – …(and the list goes on)

Wouldn’t it be nice if… You could write a C++ class that could be used in a program written in Java, Visual Basic, VB Script, Delphi, COBOL, HTML, etc? You could write a C++ class that could be loaded into a program at runtime rather than build in at compile time? You could write a C++ class that runs on a computer other than the client program using it? Your virtual sandbox is about to become much larger……

What is COM? COM – Component Object Model The basis for all of Microsoft’s component programming technology A binary specification for object interoperability – Define the specification for binary objects written in dissimilar languages to be used interchangeably

Where are COM objects used on Microsoft Platforms? More accurately, where isn’t COM used? – Operating system calls (most have COM interfaces) – DirectX (Direct Draw, Direct Show, Direct Play, …) – MAPI: messaging application programming interface – SSPI: security support provider interface (Kerberos, SSL, NTLM, etc) – Object Linking and Embedding: How is it that an Excel table can be inserted into a Word document or web page?

Why use COM? – Write an API once using COM and it is available to every development environment. – Software can be upgraded without recompiling – Software can be extended beyond it original capabilities without recompiling

Conceptually, how does COM work?

A glimpse under COM’s hood (basically) All programs are a stream of instructions that are executed sequentially – What if you could take a binary file that is know to contain a COM object and be guaranteed that certain functions begin at specific offsets in that file? – If you knew the offset of a function into a file, how would you call it, pass values to it, and get return values from it?

COM accomplishes these goals by defining: – A binary interface specification for all COM objects Offsets into BLOBs (binary large objects) where functions can be found – Programming interfaces that all COM objects must support Guarantees certain functionality always exists – Data types for use with COM objects Values passed to and from objects – Mechanisms for registering and publishing a COM objects capabilities with the operating system

What functions are guaranteed to be in a COM object? Remember, in many situations COM objects aren’t loaded into a program until after the program is running. These for will need functions to: – Identify what the object is – Identify what the object can do – Handle acquiring memory (instantiating) – Handle releasing memory (de-allocating) COM defines interfaces for these operations

What is an interface? What is a function or method? What’s the difference?

Interface = Contract Once an interface is defined, it NEVER changes …

IUnknown interface By definition, a COM object is not a COM object unless it implements the IUnknown interface – IUnknown defines the interface to three functions: IUnknown::QueryInterface() IUnknown::AddRef() IUnknown::Release() – COM defines them, YOU implement them! – Do you think the IUnknown interface will ever change?

Fishing for functionality IUnknown::QueryInterface() – Use it to ask an object what it can do – How? Pass it an identifier for an interface and a pointer if it supports the interface, it will assign the pointer to the requested interface and return S_OK If it doesn’t support the interface, it will return E_NOINTERFACE Don’t worry about the details now, just the concept of what QueryInterface is for.

GUID Globally Unique Identifiers – Every COM object is assigned a (almost) globally unique 16 byte value – Use this value to identify the COM object Same format is used to define CLSID and IID – Class Identifier – Interface Identifier

IClassFactory Used to create an instance of a COM object Inherits from IUnknown Defines the interfaces: – IClassFactory::CreateInstance() List a C++ constructor on steroids – IClassFactory::LockServer() Allows a COM object to be locked in memory so additional requests for object instances are fast

Review COM defines interfaces for binary objects that programs can interface with All COM objects implement the IUnknown interface – Used to the determine interfaces an object supports IClassFactory interface is used to create instances of an object

Quick note on where COM info is stored COM objects are registered with the operating system Information is stored in the registry – CLSID of the object – Name of the object – Where the file is that stores the object – What interfaces the object supports (IMPORTANT) – Other things…

Shortest distance between you and writing COM objects ATL: Active Template Library – A set of templates that implement a framework to create COM objects of every type Implements IUnknown and IClassFactory Implements function to register COM object with operating system Allows you to focus on implementing the functionality of the object and not the mundane tasks of implementing COM detains. Code generator

How to use ATL in VC Select File->New->Projects (pane) 1. ATL COM AppWizard (from list) 2. Dynamic Link Library (radio button) 3. Finish (button) 2. Select->Insert 1. New ATL Object 1. Objects (left list box) 2. Simple Object (right selection box)

continued 1. Enter the name of the new COM object ( based on the name you enter, the Wizard will suggest names for the classes and type libraries it will create for you) 2. Select OK 3. Right click on your newly created COM interface in the “Class View” (left pane) and select “Add Method” 1. Enter the name of the method 2. Write some code in the stub that is created 4. Compile it – as part of the compilation process, the program regsrv32.exe is run to register your object.

How is your new COM object packaged.dll The DLL is self registering (thanks to ATL) Use the regsvr32.exe program to register the dll on other computers Use regedit.exe to make sure the object was registered correctly – HKEY_CLASSES_ROOT->(project name) – In the key you will see the directory the dll is located in and the CLSID that identifies you new object.

How do you use your new object Write a test program! 1. Include a few files that were created by ATL for your project 2. Initialize COM libraries in main() 3. Create a pointer to IClassFactory for your object 4. Use IClassFactory to create an interface pointer to IUnknown 5. Query the IUnknown interface for the interface implemented by your object 6. Call method in your object 7. Release all interfaces and un-initialize COM

Scratching the surface COM is huge in every sense of the word – Server types – Threading models – DCOM – Object aggregation – Dual interfaces – Early binding (our example) vs. Late binding (used by VB) – Searching the registry for objects – …

By the way… What is ActiveX – COM objects. What are ActiveX controls – COM objects with additional interfaces implemented beyond the IUnknown interface

Further Reading 1. Win32 Platform SDK – Component Services 2. MSDN Technical Articles – Component Object Model 3. DirectX 7 SDK (good examples) 4. Any “how to” book on COM – you’ll need to guide you through the sea of function calls.