_configthreadlocale

스레드별 로캘 옵션을 구성합니다.

int _configthreadlocale(
   int type
);

매개 변수

  • type
    설정할 옵션입니다.다음 표에 나열 된 옵션 중 하나입니다.

반환 값

스레드별 로캘 이전 상태 (_DISABLE_PER_THREAD_LOCALE 또는 _ENABLE_PER_THREAD_LOCALE), 실패 시-1.

설명

_configurethreadlocale 함수를 사용 하 여 스레드별 로캘 사용을 제어할 수 있습니다.이러한 옵션 중 하나를 사용 하 여 지정 하거나 스레드별 로캘을 상태를 확인 하려면:

  • _ENABLE_PER_THREAD_LOCALE
    현재 스레드가 스레드 특정 사용 로케일을 확인 합니다.후속 호출을 setlocale 이 스레드에 스레드 자체의 로케일만에 영향을 줍니다.

  • _DISABLE_PER_THREAD_LOCALE
    현재 스레드에서 전역 로캘을 사용 하 여 확인 합니다.후속 호출을 setlocale 이 스레드에서 전역 로캘을 사용 하 여 다른 스레드가 영향을 줍니다.

  • 0
    이 특정 스레드에 대 한 현재 설정을 검색합니다.

These functions affect the behavior of setlocale, _tsetlocale, _wsetlocale, _beginthread, and _beginthreadex.로캘 설정을 다른 방법은 스레드를 만드는 데 사용 하는 경우 해당 스레드를에 영향을 주지 않습니다.

스레드별 로캘을 사용 안 함, 이후에 호출 되 면 setlocale 또는 _wsetlocale 모든 스레드의 로캘을 변경 합니다.스레드별 로캘을 사용 하는 경우 setlocale 또는 _wsetlocale 현재 스레드의 로캘에만 적용 됩니다.

사용 하는 경우 _configurethreadlocale 스레드별 로캘을 사용 하려면 호출 하는 것이 좋습니다 setlocale 또는 _wsetlocale 직후에 해당 스레드에서 기본 로케일을 설정할 수 있습니다.

경우 type 값 중 하나가 아닌 테이블에 나열 된이 함수는 잘못 된 매개 변수 처리기의 설명에 따라 호출 매개 변수 유효성 검사.실행을 계속 허용 되 면이 함수를 설정 errno 에 EINVAL 및-1을 반환 합니다.

요구 사항

루틴

필수 헤더

_configthreadlocale

<locale.h>

예제

// crt_configthreadlocale.cpp
// 
// This program demonstrates the use of _configthreadlocale when
// using is two independent threads.
//

#include <locale.h>
#include <process.h>
#include <windows.h>
#include <stdio.h>
#include <time.h>

#define BUFF_SIZE 100

// Retrieve the date and time in the current
// locale's format.
int get_time(unsigned char* str)
{
    __time64_t  ltime;
    struct tm   thetime;

    // Retieve the time
    _time64(&ltime);
    _gmtime64_s(&thetime, &ltime);

    // Format the current time structure into a string
    // using %#x is the long date representation,
    // appropriate to the current locale
    if (!strftime((char *)str, BUFF_SIZE, "%#x", 
                  (const struct tm*)&thetime))
    {
        printf("strftime failed!\n");
        return -1;
    }
    return 0;
}

// This thread sets its locale to German
// and prints the time.
unsigned __stdcall SecondThreadFunc( void* pArguments )
{
    unsigned char str[BUFF_SIZE];

    // Set the thread code page
    _setmbcp(_MB_CP_ANSI)

    // Set the thread locale
    printf("The thread locale is now set to %s.\n",
           setlocale(LC_ALL, "German"));

    // Retrieve the time string from the helper function
    if (get_time(str) == 0)
    {
        printf("The time in German locale is: '%s'\n", str);
    }

    _endthreadex( 0 );
    return 0;
} 

// The main thread spawns a second thread (above) and then
// sets the locale to English and prints the time.
int main()
{ 
    HANDLE          hThread;
    unsigned        threadID;
    unsigned char   str[BUFF_SIZE];

    // Configure per-thread locale to cause all subsequently created 
    // threads to have their own locale.
    _configthreadlocale(_ENABLE_PER_THREAD_LOCALE);

    // Retrieve the time string from the helper function
    printf("The thread locale is now set to %s.\n",
           setlocale(LC_ALL, "English"));

    // Create the second thread.
    hThread = (HANDLE)_beginthreadex( NULL, 0, &SecondThreadFunc,
                                      NULL, 0, &threadID );

    if (get_time(str) == 0)
    {
        // Retrieve the time string from the helper function
        printf("The time in English locale is: '%s'\n\n", str);
    }

    // Wait for the created thread to finish.
    WaitForSingleObject( hThread, INFINITE );

    // Destroy the thread object.
    CloseHandle( hThread );
}
  
  
  
  

해당 .NET Framework 항목

해당 사항 없음. 그러나 볼 CurrentCulture 속성을 사용 하 여.

참고 항목

참조

setlocale을 _wsetlocale

_beginthread, _beginthreadex

로캘

다중 스레딩 및 로캘