Is there an OS function to translate REFIID into a usable name?

It is not enough to write a function manually, which translates several well-known REFIID names, such as:

if (riid == IID_IUnknown) return "IUnknown";
if (riid == IID_IShellBrowser) return "IShellBrowser";
...

Is there a system call that returns a reasonable debug string for the well-known (or even all) REFIIDs?

+5
source share
2 answers

Thanks for answers. 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;
}
+6
source

You can find predefined interfaces in the registry sub-registry HKCR \ Interface. Any component can register its interfaces there if it wants. However, this is not necessary - the component may skip this registration.

+3

All Articles