Export (0) Print
Expand All

IUnknown_AtomicRelease function

Releases a Component Object Model (COM) pointer and sets it to NULL.

Syntax


void IUnknown_AtomicRelease(
  _Inout_opt_  void **ppunk
);

Parameters

ppunk [in, out, optional]

Type: void**

The address of a pointer to a COM interface.

Return value

This function does not return a value.

Remarks

If ppunk points to a NULL pointer, no operation is performed. Otherwise, ppunk is assumed to be the address of a COM interface pointer, derived from IUnknown. The function calls the interface's IUnknown::Release method then sets the interface pointer to NULL.

Examples

The following example uses IUnknown_AtomicRelease to release the stream, if it exists. If not, it does nothing.


void sample()
{
    IStream *pstm = NULL;
    CreateStreamOnHGlobal(NULL, TRUE, &pstm);
    
    IUnknown_AtomicRelease((void**)&pstm);
    
    // At this point, pstm is NULL
}

Requirements

Minimum supported client

Windows 2000 Professional, Windows XP [desktop apps only]

Minimum supported server

Windows 2000 Server, Windows Server 2003 [desktop apps only]

Header

Shlwapi.h

DLL

Shlwapi.dll (version 5.0 or later)

 

 

Community Additions

ADD
Show:
© 2014 Microsoft