# iunknown.h ## **Overview** **Related Modules:** [Samgr](Samgr.md) **Description:** Provides the base class and default implementation for external functions of system capabilities. **Since:** 1.0 **Version:** 1.0 ## **Summary** ## Data Structures

Data Structure Name

Description

IUnknown

Defines the IUnknown class.

IUnknownEntry

Defines the IUnknown implementation class.

## Macros

Macro Name and Value

Description

DEFAULT_VERSION   0x20

Defines the default IUnknown version. You can customize the version.

INHERIT_IUNKNOWN

Defines the macro for inheriting the IUnknown interface.

INHERIT_IUNKNOWNENTRY(T)

Defines the macro for inheriting the classes that implement the IUnknown interface.

DEFAULT_IUNKNOWN_IMPL

Defines the default marco for initializing the IUnknown interface.

IUNKNOWN_ENTRY_BEGIN(version)

Defines the macro for initializing the classes that implement the IUnknown interface.

IUNKNOWN_ENTRY_END   }

IUnknown Defines the end macro for initializing the IUnknown implementation object.

GET_IUNKNOWN(T)   (IUnknown *)(&((T).iUnknown))

Obtains the pointer of the IUnknown interface object from the subclass object T (generic macro) of the IUnknown implementation class.

## Typedefs

Typedef Name

Description

IUnknownEntry

typedef struct IUnknownEntry 

Defines the IUnknown implementation class.

## Functions

Function Name

Description

IUNKNOWN_AddRef (IUnknown *iUnknown)

int 

Increments the reference count in this IUnknown interface.

IUNKNOWN_QueryInterface (IUnknown *iUnknown, int ver, void **target)

int 

Queries the IUnknown interfaces of a specified version (downcasting).

IUNKNOWN_Release (IUnknown *iUnknown)

int 

Releases a reference to an IUnknown interface that is no longer used.