Thanks for the responses. Below is what I came up with based on your feedback - much appreciated!
CString ToString(const GUID & guid)
{
// could use StringFromIID() - but that requires managing an OLE string
CString str;
str.Format(_T("%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X"),
guid.Data1,
guid.Data2,
guid.Data3,
guid.Data4[0],
guid.Data4[1],
guid.Data4[2],
guid.Data4[3],
guid.Data4[4],
guid.Data4[5],
guid.Data4[6],
guid.Data4[7]);
return str;
}
CString GetNameOf(REFIID riid)
{
CString name(ToString(riid));
try
{
// attempt to lookup the interface name from the registry
RegistryKey::OpenKey(HKEY_CLASSES_ROOT, "Interface", KEY_READ).OpenSubKey("{"+name+"}", KEY_READ).GetDefaultValue(name);
}
catch (...)
{
// use simple string representation if no registry entry found
}
return name;
}