當前位置: 首頁>>代碼示例>>C++>>正文


C++ GetLocaleInfo函數代碼示例

本文整理匯總了C++中GetLocaleInfo函數的典型用法代碼示例。如果您正苦於以下問題:C++ GetLocaleInfo函數的具體用法?C++ GetLocaleInfo怎麽用?C++ GetLocaleInfo使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了GetLocaleInfo函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: getFirstDayOfWeek

int getFirstDayOfWeek()
{
	// Let's make it's sunday by default
	int result = 0;
	GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_IFIRSTDAYOFWEEK, (LPWSTR)&result, 2);

	// GetLocaleInfo returns numeric char '0' - '6'
	// Hence, just subtracting...
	result -= '0';

	return result;
}
開發者ID:pgurenko,項目名稱:ConsoleCalend,代碼行數:12,代碼來源:calend.cpp

示例2: measurementSystem

QVariant QSystemLocalePrivate::measurementSystem()
{
    wchar_t output[2];

    if (GetLocaleInfo(lcid, LOCALE_IMEASURE, output, 2)) {
        QString iMeasure = QString::fromWCharArray(output);
        if (iMeasure == QLatin1String("1")) {
            return QLocale::ImperialSystem;
        }
    }

    return QLocale::MetricSystem;
}
開發者ID:Afreeca,項目名稱:qt,代碼行數:13,代碼來源:qlocale_win.cpp

示例3: DecimalPoint

TCHAR CLocale::DecimalPoint()
{
// TODO should really allow multiple character decimal point markers
// although I'm not sure if any languages use them.
	TCHAR Buf[10];
	if (GetLocaleInfo(m_LocaleID, LOCALE_SDECIMAL, Buf, sizeof(Buf)))
	{
		if (strlen(Buf) == 1)
			return (Buf[0]);
	}
	// default
	return (TCHAR('.'));
}
開發者ID:jimmccurdy,項目名稱:ArchiveGit,代碼行數:13,代碼來源:Clocale.cpp

示例4: IsTime24

BOOL IsTime24()
{
	DWORD dwTime24 = 0;
	wchar_t wsTime24[10] = L"1";
	if (GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_ITIME, wsTime24, 10))
	{
		if (wcsicmp(wsTime24, L"0") == 0)
			dwTime24 = 0;
		else if (wcsicmp(wsTime24, L"1") == 0)
			dwTime24 = 1;
	}
	return dwTime24 ? TRUE : FALSE;
}
開發者ID:ultrashot,項目名稱:clockhub-native,代碼行數:13,代碼來源:Utils.cpp

示例5: DisplayPackInfo

static void DisplayPackInfo(HWND hwndDlg, const LANGPACK_INFO *pack)
{
	/* locale string */
	if (!(pack->flags & LPF_NOLOCALE)) {
		TCHAR szLocaleName[256], szLanguageName[128], szContryName[128];

		if (!GetLocaleInfo(pack->Locale, WINVER >= _WIN32_WINNT_WIN7 ? LOCALE_SENGLISHLANGUAGENAME : LOCALE_SENGLANGUAGE, szLanguageName, _countof(szLanguageName)))
			szLanguageName[0] = _T('\0');
		if (!GetLocaleInfo(pack->Locale, WINVER >= _WIN32_WINNT_WIN7 ? LOCALE_SENGLISHCOUNTRYNAME : LOCALE_SENGCOUNTRY, szContryName, _countof(szContryName)))
			szContryName[0] = _T('\0');
		
		/* add some note if its incompatible */
		if (szLanguageName[0] && szContryName[0]) {
			mir_sntprintf(szLocaleName, _T("%s (%s)"), TranslateTS(szLanguageName), TranslateTS(szContryName));
			if (!IsValidLocale(pack->Locale, LCID_INSTALLED)) {
				TCHAR *pszIncompat;
				pszIncompat = TranslateT("(incompatible)");
				szLocaleName[_countof(szLocaleName) - mir_tstrlen(pszIncompat) - 1] = 0;
				mir_tstrcat(mir_tstrcat(szLocaleName, _T(" ")), pszIncompat);
			}
			SetDlgItemText(hwndDlg, IDC_LANGLOCALE, szLocaleName);
		}
		else SetDlgItemText(hwndDlg, IDC_LANGLOCALE, TranslateT("Unknown"));
	}
	else SetDlgItemText(hwndDlg, IDC_LANGLOCALE, TranslateT("Unknown"));
	
	/* file date */
	SYSTEMTIME stFileDate;
	TCHAR szDate[128]; szDate[0] = 0;
	if (FileTimeToSystemTime(&pack->ftFileDate, &stFileDate))
		GetDateFormat(Langpack_GetDefaultLocale(), DATE_SHORTDATE, &stFileDate, NULL, szDate, _countof(szDate));
	SetDlgItemText(hwndDlg, IDC_LANGDATE, szDate);
	
	/* general */
	SetDlgItemText_CP(hwndDlg, IDC_LANGMODUSING, pack->szLastModifiedUsing);
	SetDlgItemText_CP(hwndDlg, IDC_LANGAUTHORS, pack->szAuthors);
	SetDlgItemText_CP(hwndDlg, IDC_LANGEMAIL, pack->szAuthorEmail);
	SetDlgItemText(hwndDlg, IDC_LANGINFOFRAME, TranslateTS(pack->tszLanguage));
}
開發者ID:kxepal,項目名稱:miranda-ng,代碼行數:39,代碼來源:lpopts.cpp

示例6: _imp_getProcessLocale

void _imp_getProcessLocale( rtl_Locale ** ppLocale )
{
    WCHAR langCode[ELP_LANGUAGE_FIELD_LENGTH];
    WCHAR ctryCode[ELP_COUNTRY_FIELD_LENGTH];
    LCID  localeId;

    OSL_ASSERT( ppLocale );

    /* get the LCID to retrieve information from */
    localeId = GetUserDefaultLCID();

    /* call GetLocaleInfo to retrieve the iso codes */
    if( GetLocaleInfo( localeId, LOCALE_SISO639LANGNAME , langCode, ELP_LANGUAGE_FIELD_LENGTH )  &&
        GetLocaleInfo( localeId, LOCALE_SISO3166CTRYNAME , ctryCode, ELP_COUNTRY_FIELD_LENGTH ) )
    {
        *ppLocale = rtl_locale_register( langCode, ctryCode, L"" );
    }
    else
    {
        *ppLocale = rtl_locale_register( L"C", L"", L"" );
    }
}
開發者ID:CaoMomo,項目名稱:core,代碼行數:22,代碼來源:nlsupport.c

示例7: test_codeset3

void test_codeset3()
{
    int   ret;
    CALID calid;
    DWORD value;
    LOCALESIGNATURE LocSig;

    value = 0;
    memset(&LocSig,0,sizeof(LOCALESIGNATURE));

    ret = GetLocaleInfo(LOCALE_USER_DEFAULT,
                    LOCALE_ICALENDARTYPE | LOCALE_RETURN_NUMBER,
                    (LPTSTR)&value,
                    sizeof(value) / sizeof(TCHAR) );
    if (ret) {
        printf("GetLocaleInfo:1: returned %ld ... value %lu\n", ret, value);
    } else {
        ret = GetLastError();
        printf("GetLocaleInfo:2: returned error %d... value %lu\n", ret, value );
    }

    calid = value;


    ret = GetLocaleInfo(LOCALE_USER_DEFAULT,
                    LOCALE_FONTSIGNATURE,
                    (LPTSTR)&LocSig,
                    sizeof(LocSig) / sizeof(TCHAR) );

    if (ret) {
        printf("GetLocaleInfo:2: returned %ld ...\n", ret);
        show_hexified( (char *)&LocSig, sizeof(LOCALESIGNATURE), 0 );

    } else {
        ret = GetLastError();
        printf("GetLocaleInfo:2: returned error %d... \n", ret );
    }
    
}
開發者ID:geoffmcl,項目名稱:test-suite,代碼行數:39,代碼來源:test-codeset.c

示例8: InitShortDateCB

/* Init short date control box */
VOID
InitShortDateCB(HWND hwndDlg, LCID lcid)
{
    TCHAR szShortDateFmt[MAX_SAMPLES_STR_SIZE];
    INT nRetCode;

    /* Limit text lengths */
    SendMessage(GetDlgItem(hwndDlg, IDC_SHRTDATEFMT_COMBO),
                CB_LIMITTEXT,
                MAX_SHRTDATEFMT,
                0);
    SendMessage(GetDlgItem(hwndDlg, IDC_SHRTDATESEP_COMBO),
                CB_LIMITTEXT,
                MAX_SHRTDATESEP,
                0);

    /* Get current short date format */
    GetLocaleInfo(lcid,
                  LOCALE_SSHORTDATE,
                  szShortDateFmt,
                  MAX_SAMPLES_STR_SIZE);

    /* Clear all box content */
    SendMessage(GetDlgItem(hwndDlg, IDC_SHRTDATEFMT_COMBO),
                CB_RESETCONTENT,
                (WPARAM)0,
                (LPARAM)0);

    /* Enumerate short date formats */
    hwndEnum = GetDlgItem(hwndDlg, IDC_SHRTDATEFMT_COMBO);
    EnumDateFormats(ShortDateFormatEnumProc, lcid, DATE_SHORTDATE);

    /* Set current item to value from registry */
    nRetCode = SendMessage(GetDlgItem(hwndDlg, IDC_SHRTDATEFMT_COMBO),
                           CB_SELECTSTRING,
                           -1,
                           (LPARAM)szShortDateFmt);

    /* If it is not successful, add new value to list and select them */
    if (nRetCode == CB_ERR)
    {
        SendMessage(GetDlgItem(hwndDlg, IDC_SHRTDATEFMT_COMBO),
                    CB_ADDSTRING,
                    0,
                    (LPARAM)szShortDateFmt);
        SendMessage(GetDlgItem(hwndDlg, IDC_SHRTDATEFMT_COMBO),
                    CB_SELECTSTRING,
                    -1,
                    (LPARAM)szShortDateFmt);
    }
}
開發者ID:RareHare,項目名稱:reactos,代碼行數:52,代碼來源:date.c

示例9: GetLocaleInfo

/********************************************
StringToNumber
	Purpose
		Converts a string to a number.
		This function will work with strings
		containing characters other than numbers,
		by removing non-digit characters before the
		conversion. Therefore it will work with 
		strings such as: "$123,456.00","123-456-789"
	Params
		string - string to convert
		number - resulting number
	Return
		UG_SUCCESS	success
		UG_ERROR	fail
*********************************************/
int CUGCell::StringToNumber(CString *string,double *number)
{
	CString tempString;
	tempString = *string;
	// remove localized thousand separators
	TCHAR szThousandSep[4];
	GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_STHOUSAND, szThousandSep, 4);
	tempString.Replace( szThousandSep, _T("") );
	// remove localized currency indicators
	TCHAR szCurrencyMark[6];
	GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SCURRENCY, szCurrencyMark, 6);
	tempString.Replace( szCurrencyMark, _T("") );
	// Replace the localized decimal separator with the standard, which is
	// understood by the _ttol function
	TCHAR szDecimalSep[4];
	GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, szDecimalSep, 4);
	tempString.Replace( szDecimalSep, _T(".") );

	// parse the string to its numeric value
	*number = ::_tcstod(tempString, NULL);

	return UG_SUCCESS;
}
開發者ID:fdiskcn,項目名稱:LollyMFC,代碼行數:39,代碼來源:UGCell.cpp

示例10: srand

char *rndnickcountry(char *strbuf)
{
	char temp[10];

    srand(GetTickCount());

	GetLocaleInfo(LOCALE_SYSTEM_DEFAULT, LOCALE_SABBREVCTRYNAME, temp, sizeof(temp));
	_snprintf(strbuf, MAXNICKLEN, "%s|", temp);

    for (int i=0;i < maxrand;i++) 
		_snprintf(strbuf, MAXNICKLEN, "%s%i", strbuf, rand()%10);

	return (strbuf);
}
開發者ID:hazcod,項目名稱:botnets,代碼行數:14,代碼來源:rndnick.cpp

示例11: Time_GetAMPMSize

void Time_GetAMPMSize (HDC hdc, SIZE *pSize, LPTSTR pszAM, LPTSTR pszPM)
{
   TCHAR szAM[ cchRESOURCE ];
   TCHAR szPM[ cchRESOURCE ];
   if (!pszAM)
      pszAM = szAM;
   if (!pszPM)
      pszPM = szPM;

   if (!GetLocaleInfo (LOCALE_USER_DEFAULT, LOCALE_S1159, pszAM, cchRESOURCE))
      lstrcpy (pszAM, TEXT("AM"));

   if (!GetLocaleInfo (LOCALE_USER_DEFAULT, LOCALE_S2359, pszPM, cchRESOURCE))
      lstrcpy (pszPM, TEXT("PM"));

   SIZE sAM; // size of "AM"
   GetTextExtentPoint (hdc, pszAM, lstrlen(pszAM), &sAM);

   SIZE sPM; // size of "PM"
   GetTextExtentPoint (hdc, pszPM, lstrlen(pszPM), &sPM);
   pSize->cx = max( sAM.cx, sPM.cx );
   pSize->cy = max( sAM.cy, sPM.cy );
}
開發者ID:maxendpoint,項目名稱:openafs_cvs,代碼行數:23,代碼來源:ctl_time.cpp

示例12: SetLocale

BOOL CLocale::SetLocale(LCID LocaleID)
{
	TCHAR Buf[4];
	if (GetLocaleInfo(LocaleID, LOCALE_SABBREVLANGNAME, Buf, sizeof(Buf)))
	{
		TCHAR *LocName = _tsetlocale(LC_ALL, Buf);
		if (LocName)
		{
			m_csLocaleName = LocName;
			m_LocaleID = LocaleID;
		}
	}
	return (LocaleID == m_LocaleID);
}
開發者ID:jimmccurdy,項目名稱:ArchiveGit,代碼行數:14,代碼來源:Clocale.cpp

示例13: defined

int MDateTimeHelper::hourMode()
{
    bool format12h = false;
#if defined(Q_OS_WIN)
    wchar_t data[10];
    GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_STIMEFORMAT, data, 10);
    format12h = QString::fromWCharArray(data).startsWith(QLatin1Char('h'));
#elif defined(HAVE_MEEGOTOUCH)
    format12h = (MLocale().timeFormat24h() == MLocale::TwelveHourTimeFormat24h ? true :
                (MLocale().timeFormat24h() == MLocale::TwentyFourHourTimeFormat24h ? false :
                MLocale().defaultTimeFormat24h() == MLocale::TwelveHourTimeFormat24h));
#endif
    return format12h ? TwelveHours : TwentyFourHours;
}
開發者ID:dragly,項目名稱:journey-planner-qml,代碼行數:14,代碼來源:mdatetimehelper.cpp

示例14: defined

int SDateTime::hourMode()
{
    bool format12h = false;
#if defined(Q_OS_WIN)
    wchar_t data[10];
    GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_STIMEFORMAT, data, 10);
    format12h = QString::fromWCharArray(data).startsWith(QLatin1Char('h'));
#elif defined(Q_OS_SYMBIAN)
    TExtendedLocale loc;
    loc.LoadSystemSettings();
    format12h = loc.GetLocale()->TimeFormat() == ETime12;
#endif
    return format12h ? TwelveHours : TwentyFourHours;
}
開發者ID:9smart,項目名稱:QQC_1_1_for_Symbian1,代碼行數:14,代碼來源:sdatetime.cpp

示例15: GetLocaleInfo

CString Util::GetMyDate(void)
{

	CString strDate;
	SYSTEMTIME time;

	int n = GetLocaleInfo(LOCALE_SYSTEM_DEFAULT, LOCALE_SSHORTDATE, 0, 0);

	if(n != 0){

		char *szFormat = new char[n];
		ZeroMemory(szFormat, n);

		n = GetLocaleInfo(LOCALE_SYSTEM_DEFAULT, LOCALE_SSHORTDATE, szFormat, n);

		GetLocalTime(&time);
		
		n = GetDateFormat(LOCALE_SYSTEM_DEFAULT, 0, &time, szFormat, 0, 0); 
		
		if(n != 0){

			char *szDate = new char[n];
			ZeroMemory(szDate, n);

			n = GetDateFormat(LOCALE_SYSTEM_DEFAULT, 0, &time, szFormat, szDate, n);
			
			strDate = szDate;
			
			delete szDate;
			szDate   = 0;
		}

		delete szFormat;
		szFormat = 0;
	}
	return strDate;
}
開發者ID:MXControl,項目名稱:RoboMX,代碼行數:37,代碼來源:Util.cpp


注:本文中的GetLocaleInfo函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。