Sunteți pe pagina 1din 17

DCOM Interfaces

IUnknown IDispatch IClassFactory

IUnknown
Enables clients to get pointers to other interfaces Manage the existence of the object through the AddRef and Release methods. All other COM interfaces are inherited, directly or indirectly, from IUnknown. Therefore, the three methods in IUnknown are the first entries in the VTable for every interface. implement IUnknown as part of every interface.

HRESULT QueryInterface( [in] REFIID riid, [out] void **ppvObject );

Retrieves pointers to the supported interfaces on an object. This method calls IUnknown::AddRef on the pointer it returns. Return value returns S_OK ->interface is supported E_NOINTERFACE otherwise. If ppvObject i= NULL,returns E_POINTER.

Set of interfaces accessible on an object through QueryInterface must be static, not dynamic. if a call to QueryInterface for a pointer to a specified interface succeeds the first time, it must succeed again, and if it fails the first time, it must fail on all subsequent queries. Reflexive Symmetric Transitive next

must be reflexive if a client holds a pointer to an interface on an object, and queries for that interface, the call must succeed.

back

must be symmetric if a client holding a pointer to one interface queries successfully for another, a query through the obtained pointer for the first interface must succeed.

back

must be transitive if a client holding a pointer to one interface queries successfully for a second, and through that pointer queries successfully for a third interface, a query for the first interface through the pointer for the third interface must succeed.
back

Binding is the term given to the process of matching the location of a function given a pointer to an object. COM supports three types of binding: Late. This is where type discovery is left until runtime. Method calls made by the client but not implemented by the object will fail at execution time. ID. Method IDs are stored at compile time, but execution of the method is still performed through a higher-level function. Custom vTable (early). Binding is performed at compile time. The client can then make method calls directly into the object.

IDispatch

The IDispatch interface supports late- and ID-binding languages.


Late binding requires a call to the object to retrieve the list of method IDs; The client must then construct the call to the Invoke method and call it. The Invoke method must then unpack the method parameters and call the function. All these steps add significant overhead to the time it takes to execute a method.

ID binding offers a slight improvement over late binding in that the method IDs are cached at compile time, which means the initial call to retrieve the IDs is not required. However, there is still significant call overhead because the IDispatch::Invoke method is still called to execute the required method on the object.

Early binding, often referred to as custom vTable binding, does not use the IDispatch interface. Instead, a type library provides the required information at compile time to allow the client to know the layout of the server object. At runtime, the client makes method calls directly into the object. This is the fastest method of calling object methods and also has the benefit of compile-time type checking.

dual

Objects that support both IDispatch and custom vTable are referred to as dual interface objects

IClassFactory
When to implement For every class that you register in the system registry and to which you assign a CLSID, so objects of that class can be created. IClassFactory::CreateInstance : creates an instance of component using CLSID IClassFactory::LockServer : increment the ref count ,server stays in memory and doesnot shutdown before client finishes its work.

IClassInterface

Before a client creates an instance of a COM object, 1. It creates an instance of the object's class factory, (using CoGetClassObject()). 2. CoGetClassObject() calls the DllGetClassObject() in the DLL. 3. It creates the classFactory instance using CLSID and IID and returns interface pointer to client 4. Using ClassFactory Instance the client then calls the class factory's ClassFactory::CreateInstance method. 5. ClassFactory::CreateInstance() creates a new instance of the component and return the interface pointer to the client

S-ar putea să vă placă și