ATL has built-in support for debugging QueryInterface calls. You enable this support using the following two-step process.
To enable QueryInterface debugging
findguid -insert
This ensures all the common IIDs are in the interfaces section of your registry. You need to only do this once.
#define _ATL_DEBUG_QI
Once you've enabled QueryInterface debugging, the debug output window of Visual C++ will display the name of each interface that is queried for on your object.