Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

uuid (C++)

Microsoft Specific

The compiler attaches a GUID to a class or structure declared or defined (full COM object definitions only) with the uuid attribute.

__declspec( uuid("ComObjectGUID") ) declarator

The uuid attribute takes a string as its argument. This string names a GUID in normal registry format with or without the { } delimiters. For example:

struct __declspec(uuid("00000000-0000-0000-c000-000000000046")) IUnknown;
struct __declspec(uuid("{00020400-0000-0000-c000-000000000046}")) IDispatch;

This attribute can be applied in a redeclaration. This allows the system headers to supply the definitions of interfaces such as IUnknown, and the redeclaration in some other header (such as COMDEF.H) to supply the GUID.

The keyword __uuidof can be applied to retrieve the constant GUID attached to a user-defined type.

END Microsoft Specific

Community Additions

© 2015 Microsoft