函数参考


_WinAPI_SetThreadLocale

Sets the current locale of the calling thread.

#Include <WinAPIEx.au3>
_WinAPI_SetThreadLocale ( $LCID )

参数

$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

返回值

成功: 返回 1.
失败: 返回 0 并设置 @error 标志为非 0 值.

注意/说明

None

相关

详情参考

在MSDN中搜索


示例/演示


#Include <APIConstants.au3>
#Include <WinAPIEx.au3>

Opt('MustDeclareVars', 1)

Global $hInstance, $Data, $Prev

$hInstance = _WinAPI_LoadLibraryEx(@ScriptDir & '\Extras\Resources.dll', $LOAD_LIBRARY_AS_DATAFILE)
If Not $hInstance Then
    MsgBox(16, 'Error', @ScriptDir & '\Extras\Resources.dll not found.')
    Exit
EndIf

; Get the language (locale) identifier for the current process
If _WinAPI_GetVersion() >= '6.0' Then
    $Prev = _WinAPI_GetThreadUILanguage()
Else
    $Prev = _WinAPI_GetThreadLocale()
EndIf

; Why is the resource name for the string with ID = 6000 is 376? 6000 / 16 + 1 = 376
$Data = _WinAPI_EnumResourceLanguages($hInstance, $RT_STRING, 376)
If IsArray($Data) Then
    For $i = 1 To $Data[0]
        If _WinAPI_GetVersion() >= '6.0' Then
            _WinAPI_SetThreadUILanguage($Data[$i])
        Else
            _WinAPI_SetThreadLocale($Data[$i])
        EndIf
        ConsoleWrite(StringFormat('%-10s - %s', _WinAPI_GetLocaleInfo($Data[$i], $LOCALE_SENGLANGUAGE), _WinAPI_LoadString($hInstance, 6000)) & @CR)
    Next
EndIf

; Restore the previous language for the current process
If _WinAPI_GetVersion() >= '6.0' Then
    _WinAPI_SetThreadUILanguage($Prev)
Else
    _WinAPI_SetThreadLocale($Prev)
EndIf