Interface in COM: Presented By: Satyajit Deshmukh (S.Y.I.F.) Under Guidance: Prof. Sandeep Sukdhev Sir

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 18

INTERFACE IN

COM
Presented by:
Satyajit Deshmukh
(S.Y.I.F.)
Under Guidance:
Prof. Sandeep Sukdhev
Sir
What is COM ?
 Component Object Model (COM) is a binary
interface standard for software componentry

introduced by Microsoft in 1993.

It is used to enable interprocess communication


and dynamic object creation in a large range of
programming languages.

 Casting between different interfaces of an object


is achieved through the QueryInterface() function.
What is COM ?
 For some applications, COM has been replaced at least to
some extent by the Microsoft .NET framework, and support
for Web Services through the Windows Communication
Foundation (WCF).

 COM objects can still be used with all .NET languages


without problems.

 COM was originally designed for suitable development and


deployment of desktop applications.

 The preferred method of inheritance within COM is the


creation of sub-objects to which method calls are delegated.
Technical details
• COM programmers build their software using COM-aware
components.
• Different component types are identified by class IDs,which
are Globally Unique Identifiers.
• Each COM component exposes its functionality through one
or more interfaces.
• COM interfaces have bindings in several languages, such
as C, C++, Visual Basic, and several of the scripting
languages.
• All access to components is done through the methods of
the interfaces. This allows techniques such as inter-
process, or even inter-computer programming
What is Interface?
• An interface is a named table of function pointers (methods)

• An interface is not a class

• An interface is not a COM component

• COM clients only interact with pointers to interfaces

• COM components can implement multiple interfaces


What is Interface?
• Interfaces are strongly typed

• Interfaces are immutable

• An interface consists of a pointer to a


virtual function table
Interface Definition Language
• IDL is a generic term for a language that lets a program or
object written in one language communicate with another
program written in an unknown language.

• An IDL file is what COM provides that allows developers to


define object-oriented classes, interfaces, structures,
enumerations and other user-defined types in a language
independent manner.

• (IDL) is a standard language for defining function and method


interfaces for distributed or component-based applications.
IDL
• It is same as c/c++ in addition of keywords like ‘Interface’ &
‘library’ for defining interfaces and collections of classes,
respectively.

• The IDL file is compiled by the MIDL compiler into a type


library (.TLB file).

• In distributed object technology, it's important that new


objects be able to be sent to any platform environment and
discover how to run in that environment.
Difference between declaration
In IDL language In C/C++ language
• Ex. a function used to • Ex. a function used to
calculate sales tax calculate sales tax
• float  calculate_tax ( in float • interface order {
taxable_amount ); float calculate_tax ([in] float
taxable_amount);
float calculate_total([in]
item_list items);
bool place_order([in,out]
item_list items);
}
Why is it so ?

• Function declarations are collected into interfaces, which


represent all the defined methods for a class.

• Once you’ve defined an interface, it can be used as a


parameter type for function declarations and may be
extended by other interfaces using the C extension
operator (:).

• In my example, I assume you’ve also created an item_list


interface, which you would use as the sole parameter of
the calculate_total and place_order functions.
COM Interfaces
• An interface is a named set of pure method prototypes.

• The interface name typically reflects the functionality of its


methods and, by convention, begins with the capital letter
‘I’.

• Thus, IMalloc might represent an interface that allocates,


frees,and manages memory.

• Similarly, ISem might be an interface that encapsulates the


functionality of a semaphore.
COM Interfaces
• As a developer, you typically define your own custom
interfaces.

• the COM interface becomes a contractual agreement


between client and server, and enables the communication
protocol to function properly.

• The contract between client and server is to provide a


service; but it is not a guarantee how that service is
implemented. The implementation details are hidden in the
CoClass.
Pointers in Interface & COM interface

• In the COM model, the communication protocol between COM


clients and servers in handled using pointers to the COM
interfaces.

• The interface pointers are used to pass data between COM


clients and COM servers.

• An interface pointer is a 32-bit pointer to an object instance


that points, in turn, to the implementation of each method in
the interface.
Obtaining the first COM interface pointer

• All interaction with a remote COM server is done via its


interface pointers and the most common way to obtain the
first interface pointer is using the function create-instance.

• This takes the CLSID of the server and returns an interface


pointer for the i-unknown interface unless another interface
name is specified.
How it works??
ANY QUESTIONS ??
THANK YOU !!!!
All of you take tea I will go for ride

You might also like