Archive for October, 2015

Uuid/IID/[SH]CLSID/GUIDFromString

October 21, 2015

Raymond Chen recently did a post about various functions that extracts a GUID from a string. He left out various pieces of information and I’m going to try to complete the picture.

Let’s start with UuidFromString. On Windows 95/98 UuidFromStringW is just a stub that returns RPC_S_CANNOT_SUPPORT. The minimum version information on MSDN is wrong in the usual way.

IID­From­String has already been covered so I’ll skip that.

Next up is CLSID­From­String. MSDN does of course not say anything about the ProgId handling but Raymond did talk about this part, I’ll just add that the implementation on Windows 8 checks if the string starts with a ‘{‘ and then tries to parse it as a GUID, otherwise it does a ProgId look-up pretty much like CLSIDFromProgID would do (I did not look at other Windows versions).

Now we’ll get to the real reason for this post. There are three more functions Raymond did not cover at all!

The first one is CLSIDFromStringWrap, exported by ordinal in SHLWAPI (version 5 and later). On Windows 8 it works like CLSID­From­String but on Windows 98/2000/XP (IE 5/6) it does not support ProgIds and works more like IID­From­String.

The second one is SHCLSIDFromString, exported by ordinal in SHELL32 (all versions) and by name in version 6 from XP.SP1 and later. MSDN fails to mention that it used to only be exported by ordinal and the version information is wrong. It works like IID­From­String except that the input string is a LPCTSTR (CHAR* on Windows 95/98 and WCHAR* on NT based systems).

The third one is RtlGUIDFromString in NTDLL (Windows 2000 and later). Because it takes a UNICODE_STRING it is mostly useful for kernel developers.

Our journey ends with GUIDFromString. This function is actually implemented in both SHELL32 (version 4.71 and later) and in SHLWAPI (version 5 and later). MSDN documents the ordinals but fails to document the minimum dll versions.

Advertisements