IUnknown_Set

This function provides some common code for simultaneously saving a new interface pointer and releasing an old one.

Declaration

VOID
IUnknown_Set (
    PVOID *ppunk,
    PVOID punk);

Parameters

The ppunk argument provides the address of a pointer variable, which may already hold an old interface pointer.

The punk argument provides a new interface pointer, or is NULL.

Behaviour

If the old and new interface pointers are the same, the function does nothing.

The function releases any old interface pointer that is already in the pointer variable (including to clear the pointer variable). If the punk argument is not NULL, the function adds a reference to the new interface and saves the new interface pointer in the pointer variable.

Availability

The IUnknown_Set function is exported from SHLWAPI.DLL as ordinal 199 in version 5.00 and higher.

Though this function dates from as long ago as 1999, it was still not documented by Microsoft in the MSDN Library at least as late as the CD edition dated January 2004.

However, the function did eventually get documented, apparently later in 2004. This article now conforms to Microsoft’s nomenclature.