A GUID and a CLSID and an IID are all the same as a UUID, but there are separate functions for converting a string into a GUID, CLSID, IID, and UUID. Are they all equivalent? If not, what's the difference? And which one should I use?
The basic form for a UUID string is
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx where each
is a hexadecimal digit, case-insensitive.
(I personally prefer all-uppercase.)
All of the parsing functions under discussion use this basic form
as their basis of exploration.
Some functions expect the basic form to be enclosed in curly braces;
others do not.
Let's start with
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
Next up is
This function takes a string in basic form
with curly braces.
It also has the behavior that passing
NULL as the string
results in success and
Slightly more complicated is
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.
For example, if you ask for
it will return the GUID
As with the other functions, passing
NULL is valid
and results in
This function is one of those
"Not guaranteed to be supported beyond Windows Vista" functions,
so you should probably steer clear.
(Another clue that calling it is probably a bad idea:
The function is not exposed in any header file
or import library.)
But if you insist:
It accepts a brace-enclosed string,
NULL is not allowed.
Furthermore, it ignores any garbage after the trailing brace.
This function was
not intended for public consumption,
so these strange quirks are not entirely unexpected.
Let's summarize in a table, since that seems to be popular. I added a final column describing whether the function available in A/W variants or is Unicode-only.
|Function||Expected format||NULL allowed?||Character set support|
||Yes||ANSI and Unicode|
||No||ANSI and Unicode|