Wednesday, April 25, 2007

Display the GUID name

The following fn used to Display the GUID name.


char* GetGUIDName(const GUID &guid)
{
static char fourcc_buffer[20];
struct TGUID2NAME
{
char *szName;
GUID guid;
};
#define OUR_GUID_ENTRY(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
{ #name, { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } } },
TGUID2NAME names[] =
{
#include
};

if(guid==GUID_NULL)
{
return "GUID_NULL";
}
for(int i=0;i {
if(names[i].guid==guid)
{
return names[i].szName;
}
}
//if we get here, the return value is only valid until the next call to this function
if(guid.Data2==0 && guid.Data3==0x10 && ((DWORD *)guid.Data4)[0]==0xaa000080 && ((DWORD *)guid.Data4)[1]==0x719b3800)
{
char tmp[sizeof(DWORD)+1];
memset(tmp,0,sizeof(DWORD)+1);
memcpy(tmp,&guid.Data1,sizeof(DWORD));
_snprintf(fourcc_buffer,20,"FOURCC '%s'",tmp);
return fourcc_buffer;
}
BYTE *Uuid=NULL;
static char uuidbuffer[50];
UuidToString(const_cast(&guid), &Uuid);
sprintf(uuidbuffer,"{%s}",Uuid);
RpcStringFree(&Uuid);
return uuidbuffer;
}

No comments: