What is IUnknown? What methods are provided byIUnknown?
It is a generally good idea to have an answer for this question if you claim you know COM in your resume.Otherwise, you may consider your interview failed at this point. IUnknown is the base interface of COM. All other interfaces must derive directly or indirectly from IUnknown.There are three methods in that interface: AddRef, Releaseand QueryInterface.
What are the purposes of AddRef, Release andQueryInterface functions?
AddRef increments referencecount of the object, Release decrements reference counter of the object and QueryInterface obtains a pointer to therequested interface.
What should QueryInterface functions do if requestedobject was not found?
nullify its out parameter.
How can would you create an instance of the object inCOM?
Well, it all depends on your project. Start your answer from CoCreateInstance or CoCreateInstanceEx,explain the difference between them. If interviewer is still notsatisfied, you’ll have to explain the whole kitchen behind thescenes, including a difference between local server andinproc server, meaning and mechanism of class factory, etc.You may also mention other methods of object creation likeCoGetInstanceFromFile, but discussion will likely turn todiscussion of monikers then.
What happens when client calls CoCreateInstance?
Again, all depends on the level of detail and expertise of interviewer. Start with simple explanation of class object andclass factory mechanism. Further details would depend on aspecific situation.
What the limitations of CoCreateInstance?
Well, the major problems with CoCreateInstance is that it is only able tocreate one object and only on local system. To create aremote object or to get several objects, based on single