1. What is In-proc?

In-proc server is a COM component, when instance is the
server is loaded into the caller process space. In-Proc
server can be easily identified by .dll extension.

Out-of-Proc server is a COM component that run in its own
process space and for any instances created by the users, a
proxy is created within the users process space. Proxy is
responsible for interacting with the server to carry out
operation on behalf of the client. (.exe extension).

2. Suppose we have object B and aggregated object C (in- proc server), created by B. Can you access any interface of B from C? What?s the difference between aggregated and contained objects?

For the first question, Yes, we can since the QueryInterface
() rules of thumb suggest that if we can query an interface
of C from B, we should be able to query the viceversa.
The IUnknown implementation of both the objects has to do
the 'magic'.

For the second question, Aggregation bounds outer and inner
objects together and gives the user the interface pointers
of either objects to access it directly so that the user
never knows the objects are aggregated.

But when containment is used, the interface of inner object
never exposed to the client directly rather the outer
object receives the calls and forwards internally. Here
also, the user doesn't know the objects are contained.

3. What is a moniker?

An object that implements the IMoniker interface. A moniker
acts as a name that uniquely identifies a COM object. In
the same way that a path identifies a file in the file
system, a moniker identifies a COM object in the directory

4. What is the difference, if any, between OLE and COM?

OLE is a set of technologies to support linking and
embedding. COM lies in OLE as one of the technologies. COM
defines a binary standard / set of rules for developing
reusable components.

5. How to create an instance of the object in COM?

To create the instance of COM componet use the following
To access the component that was there in local system use
following API
CoCreateInstance(clsid,NULL(used for
&pRequestedInterface );

To access the COM componet remotely use the following API

6. What happens when client calls CoCreateInstance?

- Reads RootClassesProgId for the matching ProgID
- Reads RootClassesProgId for the matching CLSID. The
CLSID is read from the above step.
- From the CLSID key, the server type and image filename is
- Depending upon the server type, it starts the server.
- Calls CoGetClassObject function to get a handle to the
factory object.
- Then calls createinstance on the factory interface to get
the pointer to the derived object.

7. What should QueryInterface functions do if requested object was not found?

eturns a pointer to the current interface if successful or
E_NOINTERFACE otherwise.

8. What is IUnknown? What methods are provided by IUnknown?

IUnknown is a type of COM Interface.

Every COM class implements an interface named IUnKnown.

IUnKnown contains three methods:
1) HRESULT QueryInterface()
2) ULONG AddRef()
3) ULONG Release()

9. What are the purposes of AddRef, Release and QueryInterface functions?

Query Interface method is used to get the pointer to the
interface specified in one of the parameters of this
method. Client then uses this pointer to call the method of
the component.
AddRef and Release are used to increase and decrease the
count of the instance of component loaded in memory
respectively. when the count reaches zero the component is