CompareString
This function compares two character strings, using the locale specified by the identifier as the basis for the comparison.
Syntax
int CompareString( LCID Locale, DWORD dwCmpFlags,
LPCTSTR lpString1, int cchCount1, LPCTSTR lpString2, int cchCount2 );
Parameters
- Locale
- Specifies the locale used for the comparison. This parameter can be one of the following predefined locale identifiers:
- LOCALE_SYSTEM_DEFAULT
- The system’s default locale
- LOCALE_USER_DEFAULT
- The current user’s default locale
This parameter can also be a locale identifier created by the MAKELCID macro.
- dwCmpFlags
- Indicate how this function compares the two strings. The SORT_STRINGSORT flag is assumed and cannot be disabled. The NORM_IGNORECASE flag can be added as an option to ignore differences between uppercase and lowercase characters in the two strings.
- lpString1
- Pointer to the first string to be compared.
- cchCount1
- Specifies the number of characters in the string pointed to by the lpString1 parameter. If this parameter is –1, the string is assumed to be null terminated, and the length is calculated automatically.
- lpString2
- Pointer to the second string to be compared.
- cchCount2
- Specifies the number of characters in the string pointed to by the lpString2 parameter. If this parameter is –1, the string is assumed to be null terminated, and the length is calculated automatically.
Return Values
One of the following values indicates success:
- 1
- The string pointed to by the lpString1 parameter is less in lexical value than the string pointed to by the lpString2 parameter.
- 2
- The string pointed to by lpString1 is equal in lexical value to the string pointed to by lpString2.
- 3
- The string pointed to by lpString1 is greater in lexical value than the string pointed to by lpString2.
Zero indicates failure, and GetLastError may return one of the following error values:
- ERROR_INVALID_FLAGS
- ERROR_INVALID_PARAMETER
If the return value is 2, the two strings are equal in the collation sense, though not necessarily identical.
Remarks
To maintain the C run-time convention of comparing strings, the return value for strings that are equal can be 0, instead of 2.Currently, this function is available only in Windows CE version 2.10.