Geoff Chappell - Software Analyst
This function compares Unicode strings, allowing for special sequences, especially of numbers.
int StrCmpLogicalW (PCWSTR psz1, PCWSTR psz2);
The psz1 and psz2 arguments are addresses of null-terminated Unicode strings to compare.
The function returns -1, 0 or 1 as indicating that the string at psz1 is respectively less than, equal to or greater than the string at psz2.
The function treats each string as a sequence of meta-characters. One class of meta-character is the number, which begins with a decimal digit and continues for as many decimal digits as follow without interruption. Another class is the single character represented by 0x002E, i.e., the period or dot or decimal point. However, recognition of the period as its own type of meta-character is version-dependent and is anyway subject to a policy setting (see below). Any character that is not assigned to a meta-character by the preceding cases is its own meta-character.
These classes of meta-characters are ordered (from lesser to greater):
In general, numbers are compared by their numerical values. Characters are compared (in the sense of the Windows API function CompareString) according to the current thread locale, or failing that, the system default locale.
A particular case is made for leading zeros in numbers. Of two numbers that have the same numerical value, the lesser for the comparison is whichever has the more leading zeros. However, this is acted on only if the two strings turn out to be otherwise equal. For example:
"a1b1" < "a01b2" < "a1b2" < "a01b3"
Treatment of the period as a meta-character starts with the build of version 6.0 from Windows Vista. It is disabled if the following registry setting, which has programmatic support as the Windows Policy POLID_NoDotBreakInLogicalCompare, evaluates as true:
The keys are listed in decreasing order of precedence. For interpretation, see Windows Policies.
The StrCmpLogicalW function is exported by name from SHLWAPI versions 6.0 and higher.