The crux if the issue is that CComPtr<t> manages this to a large extent, maintaining its own reference and calling AddRef() when created and Release() when destroyed (using the RAII idiom (RAII - Wikipedia
]). Whenever you hold a pointer to a COM object, generally wrap it in a CComPtr<t> and C++ will correctly managed AddRef/Release for you.
Occasionally, you can use a pointer to the interface directly. For example, if a function you write receives an IMFMediaSession* as a parameter, and the only way you use the parameter is to directly call methods (using -> ), then you don't need to use AddRef/Release (be sure to check for null though).
The main consideration is lifetime of the reference. Always, for example, use CComPtr<t> for:
1. Members of a class or struct, where the sub-object will get destructed (hence Released) when the object is destroyed.
2. In a method, when you invoke another function that may possibly copy the reference (if you're not sure - use CComPtr<t> for safety.
Hope this helps.
The COM overview is here Component Object Model
Rules for managing reference counts are here: Reference Counts