Creating the Object

Given a CLSID, the client must now create an object of that class in order to make use of its services. It does so using two steps:

  1. Obtain the "class factory" for the CLSID.
  2. Ask the class factory to instantiate an object of the class, returning an interface pointer to the client.
After these steps, illustrated in Figure 5-1, the client is free to do whatever it wishes with the object through whatever interfaces the object supports. In fact, everything done with the object is accomplished through calls to interface member functions—APIs that seems to affect objects through other means are merely wrappers to common sequences of interface calls.

Before examining each of these steps, let's take a look at what a class factory is in the first place.