SafeRelease
Many of the code examples in this documentation use the following function to release COM interface pointers.
template <class T> void SafeRelease(T **ppT)
{
if (*ppT)
{
(*ppT)->Release();
*ppT = NULL;
}
}
Note
This function is not defined in an SDK header. To use this function, you must define it in your own code.
This function releases the pointer ppT and sets it equal to NULL.
Another option is to use a smart pointer class, such as CComPtr, which is defined in the Active Template Library (ATL).
Related topics
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for