c++windowsguiduuidclsid

In Windows, is there a difference between UuidFromString and CLSIDFromString?


I would just like to double-check which one is correct to use for internally generated GUIDs that bear no relation to COM classes.

My suspicion is that it's UuidFromString, but I keep seeing code that uses CLSIDFromString. I have a vague recollection that CLSIDFromString may enumerate the COM classes listed in the registry, but am not sure whether this is correct.


Solution

  • I would use UuidFromString - the documentation for CLSIDFromString explicitly states that it's purpose is to convert strings generated by StringFromCLSID back into a CLSID.

    Even if the behavior of the two functions is identical (and I suspect it may not be - consider, for example, that CLSIDFromString can return REGDB_E_CLASSNOTREG indicating the class isn't registered or REGDB_E_READREGDB which indicates a registry I/O error) it's good practice to distinguish between a CLSID and your own internal GUID objects.