假设我们有一个指向com接口的指针,所以我的问题是我们需要在Release()调用后将指针设置为null.或者COM如何处理它?
Func1()
{
.....
.....
pComInterface->Release();
pComInterface = NULL; //---> Does this required? If used, then what is the impact?
}
Run Code Online (Sandbox Code Playgroud)
我假设pComInterface是一个原始指针,声明为例如:
IFoo* pComInterface
不,你不需要NULL它 - 它只是你的局部变量.IUnknown::Release但是,调用是强制性的,因为您通知对象释放指针,并且对象可以安全地减少其内部引用计数器(如果有).