Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Implementing IClassFactory

When a client uses a CLSID to request the creation of an object instance, the first step is creation of a class object, an intermediate object that contains an implementation of the methods of the IClassFactory interface. While COM provides several instance creation functions, the first step in the implementation of these functions is the creation of a class object.

As a result, all servers must implement the methods of the IClassFactory interface, which contains two methods:

  • CreateInstance. This method must create an uninitialized instance of the object and return a pointer to a requested interface on the object.
  • LockServer. This method just increments the reference count on the class object to ensure that the server stays in memory and does not shut down before the client is ready for it to do so.

To enable a server to be responsible for its own licensing, COM defines IClassFactory2, which inherits its definition from IClassFactory. Thus, a server implementing IClassFactory2 must, by definition, implement the methods of IClassFactory.

COM also provides helper functions for implementing out-of-process servers. For more information, see Out-of-Process Server Implementation Helpers.

Related topics

COM Server Responsibilities
Licensing and IClassFactory2

 

 

Show:
© 2017 Microsoft