Windows API Guide - Reference - Volume 1: Version 3.0 For the MS-DOS and PC-DOS Operating Systems
Declare Function SetThreadLocale Lib "kernel32.dll" (ByVal Locale As Long) As Long
Platforms
- Windows 95: Not Supported.
- Windows 98: Not Supported.
- Windows NT: Requires Windows NT 3.1 or later.
- Windows 2000: Supported.
- Windows CE: Not Supported.
Description & Usage
SetThreadLocale chooses which locale to assign to the thread calling the function (i.e., the thread from your program). This locale should then be used whenever the program displays certain data to the user.
Return Value
If an error occured, the function returns 0 (use GetLastError to get the error code). If successful, the function returns a non-zero value.
Visual Basic-Specific Issues
None.
Parameters
- Locale
- The identifier of the locale to assign to the calling thread. This can also be one of the following flags:
- LOCALE_SYSTEM_DEFAULT
- The system's default locale.
- LOCALE_USER_DEFAULT
- The user's default locale.
Constant Definitions
Const LOCALE_SYSTEM_DEFAULT = &H400 Const LOCALE_USER_DEFAULT = &H800
Example
' This code is licensed according to the terms and conditions listed here. ' Assign the system's current locale to this thread. Note that ' this could be significantly different than the locale previously ' assigned to the thread! Then use the newly selected locale ' to display the current date. Dim retval As Long ' return value Dim today As SYSTEMTIME ' today's date and time Dim datestr As String ' receives the formatted date string Dim strlen As Long ' length of the buffer for the formatted date string ' First of all, set the locale to the system's default. retval = SetThreadLocale(LOCALE_SYSTEM_DEFAULT) ' Get today's date and time in the local time zone. GetLocalTime today ' Make sufficient room in the buffer to receive the date string. datestr = Space(255) ' Format today's date as a Long Date. strlen = GetDateFormat(0, DATE_LONGDATE, today, CLng(0), datestr, Len(datestr)) ' Remove the empty space from the formatted date string. datestr = Left(datestr, strlen) ' Display today's date as a Long Date. Debug.Print "Today is "; datestr
See Also
GetThreadLocale
Category
National Language Support
Go back to the alphabetical Function listing. Go back to the Reference section index.
Last Modified: January 4, 2000 This page is copyright © 2000 Paul Kuliniewicz. Copyright Information Revised October 29, 2000 Go back to the Windows API Guide home page. E-mail: vbapi@vbapi.com Send Encrypted E-Mail This page is at http://www.vbapi.com/ref/s/setthreadlocale.html