CreateInstanceAggregationCheck

CreateInstanceAggregationCheck

The CreateInstance method of IClassFactory takes pUnkOuter as the second member. This parameter must be NULL unless the class supports aggregation, which many don't. If the object the class factory creates doesn't support aggregation, pUnkOuter should be checked to make sure it is NULL.

This usually means adding code like the following at the top of the factory's CreateInstance method:

   if( pUnkOuter )
      return CLASS_E_NOAGGREGATION;

There appears to be quite a few COM object in which that is not done. See an example patch of how to fix this problem.


CategoryJanitorialProjects

CreateInstanceAggregationCheck (last edited 2011-06-03 22:59:21 by MichaelStefaniuc)