From a C ++ point of view, what you do is fine. Calling delete on a null pointer is no-op. However, this is not necessary.
From the point of view of VC ++ 6, I can’t say that, as you know, it does not meet the requirements. I can’t imagine why this could be a problem. But then again, this is definitely not necessary.
Definitely do not call delete on this pointer before it sets to NULL. You have not allocated a new one, so do not call delete. Resource management here takes care of COM functions.
source share