Compares two character strings for a specified locale.
#Include <WinAPIEx.au3>
_WinAPI_CompareString ( $LCID, $sString1, $sString2 [, $iFlags] )
$LCID | The locale identifier (LCID) that specifies the locale or one of the following predefined values. $LOCALE_INVARIANT $LOCALE_SYSTEM_DEFAULT $LOCALE_USER_DEFAULT Windows Vista or later $LOCALE_CUSTOM_DEFAULT $LOCALE_CUSTOM_UI_DEFAULT $LOCALE_CUSTOM_UNSPECIFIED |
$sString1 | The first string to compare. |
$sString2 | The second string to compare. |
$iFlags | [可选参数] The flags that indicate how the function compares the two strings. This parameter can be 0 or combination of the following values. $LINGUISTIC_IGNORECASE $LINGUISTIC_IGNOREDIACRITIC $NORM_IGNORECASE $NORM_IGNOREKANATYPE $NORM_IGNORENONSPACE $NORM_IGNORESYMBOLS $NORM_IGNOREWIDTH $NORM_LINGUISTIC_CASING $SORT_STRINGSORT Windows 7 or later $SORT_DIGITSASNUMBERS |
Success | The one of the following values that indicates a result of the comparison strings. |
失败: | 返回 0 并设置 @error 标志为非 0 值. |
在MSDN中搜索
#Include <APIConstants.au3>
#Include <Array.au3>
#Include <WinAPIEx.au3>
Opt('MustDeclareVars', 1)
If _WinAPI_GetVersion() < '6.1' Then
MsgBox(16, 'Error', 'Require Windows 7 or later.')
Exit
EndIf
Global $Item, $Temp
; Create array of strings ("Item*")
Dim $Item[100]
For $i = 0 To UBound($Item) - 1
$Item[$i] = 'Item' & Random(0, 100, 1)
Next
_ArrayDisplay($Item)
; Simple array sorting
_ArraySort($Item)
_ArrayDisplay($Item)
; Sort array (bubble sort) ignoring case sensitive and according to the digits
For $i = 0 To UBound($Item) - 2
For $j = $i + 1 To UBound($Item) - 1
Switch _WinAPI_CompareString($LOCALE_INVARIANT, $Item[$i], $Item[$j], BitOR($NORM_IGNORECASE, $SORT_DIGITSASNUMBERS))
Case $CSTR_GREATER_THAN
$Temp = $Item[$i]
$Item[$i] = $Item[$j]
$Item[$j] = $Temp
Case Else
EndSwitch
Next
Next
_ArrayDisplay($Item)