cwinapidllexportshell32

Why is SHGetPathFromIDList function exported three times


I know that shell32.dll exports two types of functions—ANSI and UNICODE. (For the sake of simplicity, I am talking only about functions that take CHAR*/WCHAR* arguments.)

For example, ShellMessageBoxA is the ANSI version, while ShellMessageBoxW is the Unicode version. ShellMessageBox is a macro defined in the header file:

#ifdef UNICODE
#define ShellMessageBox  ShellMessageBoxW
#else
#define ShellMessageBox  ShellMessageBoxA
#endif // !UNICODE

So ShellMessageBox does not exist as a function that is exported from Shell32.dll.

But now I discovered that SHGetPathFromIDList is exported three times:

What is purpose of this?


Solution

  • SHGetPathFromIDList is for legacy programs that originally targeted older versions of Windows that did not have the A and W exports because it did not support Unicode. This export is the ANSI version.

    SHGetPathFromIDListA and SHGetPathFromIDListW are the ANSI and Unicode versions.

    If you inspect the entry points with dumpbin or Dependency Walker you will see that the entry point for SHGetPathFromIDList is identical to that for SHGetPathFromIDListA.

    Modern SDKs will link to either SHGetPathFromIDListA or SHGetPathFromIDListW, but never to SHGetPathFromIDList.