Compares two Unicode strings to test binary equivalence.
int CompareStringOrdinal( _In_NLS_string_(cchCount1)LPCWCH lpString1, int cchCount1, _In_NLS_string_(cchCount2)LPCWCH lpString2, int cchCount2, BOOL bIgnoreCase );
Pointer to the first string to compare.
Length of the string indicated by lpString1. The application supplies -1 if the string is null-terminated. In this case, the function determines the length automatically.
Pointer to the second string to compare.
Length of the string indicated by lpString2. The application supplies -1 if the string is null-terminated. In this case, the function determines the length automatically.
TRUE if the function is to perform a case-insensitive comparison, using the operating system uppercase table information. The application sets this parameter to FALSE if the function is to compare the strings exactly as they are passed in. Note that 1 is the only numeric value that can be used to specify a true value for this boolean parameter that does not result an invalid parameter error. Boolean values for this parameter work as expected.
Returns one of the following values if successful. To maintain the C runtime convention of comparing strings, the value 2 can be subtracted from a nonzero return value. Then, the meaning of <0, ==0, and >0 is consistent with the C runtime.
- CSTR_LESS_THAN. The value indicated by lpString1 is less than the value indicated by lpString2.
- CSTR_EQUAL. The value indicated by lpString1 equals the value indicated by lpString2.
- CSTR_GREATER_THAN. The value indicated by lpString1 is greater than the value indicated by lpString2.
- ERROR_INVALID_PARAMETER. Any of the parameter values was invalid.
This function tests for binary equality, not linguistic equality. For information about the use of the function for ordinal sorting, see Handling Sorting in Your Applications.
Applications that are concerned with linguistic equality should use CompareString, CompareStringEx, lstrcmp, or lstrcmpi. For more information about linguistic sorting, see Handling Sorting in Your Applications
Starting with Windows 8: CompareStringOrdinal is declared in Stringapiset.h. Before Windows 8, it was declared in Winnls.h.
|Minimum supported client||Windows Vista [desktop apps | UWP apps]|
|Minimum supported server||Windows Server 2008 [desktop apps | UWP apps]|
|Header||stringapiset.h (include Windows.h)|