__declspec,uuid,__uuidof 使用说明

  用来获取 某种结构、接口及其指针、引用、变量 所关联的GUID,类似于某些语言中获取类型 typeof 这样的操作。
假定c++中,有结构体s:

struct s
{
  int i;
};

struct __declspec(uuid("93A1665E-C9FA-4147-AC3A-3CC855281AF8")) s;

s a, *b, &c;
__uuidof(s);
__uuidof(a);
__uuidof(b);
__uuidof(c);

REFCLSID,REFIID,CLSID,IID,GUID = __uuidof(x)

都能得到结构s关联的GUID:("93A1665E-C9FA-4147-AC3A-3CC855281AF8")

posted @ 2018-12-28 16:33  傍风无意  阅读(589)  评论(0)    收藏  举报