Microsoft DirectX 8.0 |
Manages the lifetime of a Component Object Model (COM) component and queries the component for other COM interfaces. All other COM interfaces inherit IUnknown.
This interface and its methods are fully described in the COM documentation and are included here only for quick reference.
If you implement an interface, you must implement IUnknown as well. The CUnknown base class provides a convenient way to implement IUnknown, but you can write your own implementation if you prefer. For more information, see How to Implement IUnknown.
Methods in Vtable Order
IUnknown methods Description QueryInterface Retrieves pointers to supported interfaces. AddRef Increments the reference count. Release Decrements the reference count.
Increments the reference count for the calling interface on an object. It should be called for every new copy of a pointer to an interface on a given object.
Syntax
ULONG AddRef(void);
Return Value
Returns an integer from 1 to n, the value of the new reference count. This information is meant to be used for diagnostic/testing purposes only, because, in certain situations, the value might be unstable.
Retrieves a pointer to a specified interface on a component to which a client currently holds an interface pointer. This method must use IUnknown::AddRef on the pointer it returns.
Syntax
HRESULT QueryInterface(
REFIID iid,
void **ppvObject
);
Parameters
- iid
- [in] Value specifying the IID of the interface being requested.
- ppvObject
- [out] Address of a pointer to the object on return. If the object doesn't support the interface specified in iid, ppvObject is set to NULL.
Return Value
Returns S_OK if the interface is supported, E_NOINTERFACE if not.
Decrements the reference count for the calling interface on an object. If the reference count on the object falls to zero, the object is freed from memory.
Syntax
ULONG Release(void);
Return Value
Returns the resulting value of the reference count, which is used for diagnostic/testing purposes only. If you need to know that resources have been freed, use an interface with higher-level semantics.