__uuidof
構文
__uuidof(EXPR)
説明
__uuidof
は、式に関連付けられた GUID を取得します。 例:
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}"
この演算子を使って、インターフェイスに関連付けられた GUID 値を取得することができます。 これは、QueryInterface 関数を使用する際に必要となります。例:
HRESULT hres = SpecificClassInstance->QueryInterface(__uuidof(ISpecificInterface), &specificInterfaceInstance);
if (S_OK == hres) // ...