__uuidof

From RAD Studio
Jump to: navigation, search

Go Up to Keywords, Alphabetical Listing Index


Syntax

__uuidof(EXPR)

Description

__uuidof retrieves the GUID associated with the expression. Example:

struct __declspec(uuid("{66AF87D4-0A13-49EB-B540-36A180FA53FA}")) TNode {
    float relevance;
};

// ...
TGUID guid = __uuidof(TNode);
ShowMessage(GUIDToString(guid)); // displays a message box with text "{66AF87D4-0A13-49EB-B540-36A180FA53FA}"

You can use this operator to get the GUID value associated with an interface. This is necessary when using the QueryInterface function. Example:

HRESULT hres = SpecificClassInstance->QueryInterface(__uuidof(ISpecificInterface), &specificInterfaceInstance);
if (S_OK == hres) // ...

See Also