Domanda

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.

È stato utile?

Soluzione 2

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.

Altri suggerimenti

Raymond Chen answers this:

Uuid­From­String:

Let's start with Uuid­From­String. It takes a string in basic form without curly braces. As a special case, if you pass NULL instead of a valid string pointer, the function still succeeds and sets the result to GUID_NULL.

CLSID­From­String:

Slightly more complicated is CLSID­From­String. In addition to accepting a brace-enclosed string (which is treated as a GUID), it also accepts a ProgId. In the ProgId case, it returns the CLSID associated with that ProgId.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top