Geoff Chappell - Software Analyst
This function parses a resource location string.
int PathParseIconLocation (LPTSTR pszIconFile);
The function exists in ANSI and Unicode forms.
The pszIconFile argument provides the address of a null-terminated string in a standard notation for specifying the pathname of an executable and either a resource index or resource ID.
If the function succeeds, it returns the (positive) resource index or (negative) resource ID, and the input string is modified to be just the pathname. Failure is indicated by returning zero.
If pszIconFile is NULL, the function has nothing to parse, and fails.
The input string is expected to end with a comma, any number of spaces or minus signs, an uninterrupted sequence of one or more decimal digits, and then any number of characters other than a comma. If the input string does not fit this format, then the resource index or ID is zero and the whole input string is treated as a pathame (see below).
Otherwise, the characters before the comma become the pathname and the characters after the comma are interpreted as the resource index or ID. If there are spaces or more than one minus sign between the comma and the decimal digits, then the resource index or ID is zero. (This may be an unintended consequence of the StrToInt function being misdocumented as supporting leading white space.) Evaluation of the decimal digits gives the resource index or ID. If a minus sign precedes the decimal digits, the evaluation is negated and denotes a resource ID.
Whatever is parsed as the pathname is processed in place. If the pathname is not the whole of the input string, it is null-terminated at the separating comma. Enclosing double-quotes are removed, and then so are leading and trailing spaces.
The PathParseIconLocation function is exported by name (with ANSI and Unicode suffixes) from SHLWAPI in version 4.70 and higher. It is also exported from SHELL32.DLL as ordinal 249 (in ANSI for Windows builds and Unicode for NT builds) in version 4.00 and higher. The implementation in SHELL32 version 4.71 and higher is just to dump to the coding in SHLWAPI.
This function has been documented since some time in 1997-98. Though it dates from 1996 in SHLWAPI and from 1995 elsewhere, it has always been said to require at least SHLWAPI version 4.71.