You should just nest the CComPtr stuff in a separate block:

void foo()

{
CoInitialize(NULL);

// BLOCK:
{
CComPtr p(something);

// yada yada
}

CoUninitialize();
}


The end of the enclosing block will cause the destructors to be called before you reach the CoUninitialize call.
_________________________
-- roger