本文整理汇总了C++中GetUserDefaultLCID函数的典型用法代码示例。如果您正苦于以下问题:C++ GetUserDefaultLCID函数的具体用法?C++ GetUserDefaultLCID怎么用?C++ GetUserDefaultLCID使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetUserDefaultLCID函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: win32_test_special_locales
void
win32_test_special_locales(void)
{
nsresult result;
nsCOMPtr<nsIWin32Locale> win32Locale;
nsCOMPtr<nsILocaleFactory> xp_locale_factory;
nsCOMPtr<nsILocale> xp_locale;
nsString* locale, *result_locale, *category;
LCID sys_lcid, user_lcid;
PRUnichar *lc_name_unichar;
win32Locale = do_CreateInstance(kWin32LocaleFactoryCID, &result);
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: factory_create_interface failed");
xp_locale_factory = do_GetClassObject(kLocaleFactoryCID, &result);
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: factory_create_interface failed");
category = new nsString(localeCategoryList[0]);
//
// derive a system locale
//
result = xp_locale_factory->GetSystemLocale(getter_AddRefs(xp_locale));
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: factory_create_interface failed");
sys_lcid = GetSystemDefaultLCID();
locale = new nsString();
result_locale = new nsString();
result = win32Locale->GetXPLocale(sys_lcid,locale);
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: factory_create_interface failed");
result = xp_locale->GetCategory(category, &lc_name_unichar);
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: factory_create_interface failed");
result_locale->SetString(lc_name_unichar);
delete result_locale;
//
// derive a system locale
//
result = xp_locale_factory->GetApplicationLocale(getter_AddRefs(xp_locale));
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: factory_create_interface failed");
user_lcid = GetUserDefaultLCID();
locale = new nsString();
result_locale = new nsString();
result = win32Locale->GetXPLocale(user_lcid,locale);
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: factory_create_interface failed");
result = xp_locale->GetCategory(category, &lc_name_unichar);
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: factory_create_interface failed");
result_locale->SetString(lc_name_unichar);
delete result_locale;
delete category;
}
示例2: GetUserDefaultLCID
LanguageType Application::getCurrentLanguage()
{
LanguageType ret = LanguageType::ENGLISH;
LCID localeID = GetUserDefaultLCID();
unsigned short primaryLanguageID = localeID & 0xFF;
switch (primaryLanguageID)
{
case LANG_CHINESE:
ret = LanguageType::CHINESE;
break;
case LANG_ENGLISH:
ret = LanguageType::ENGLISH;
break;
case LANG_FRENCH:
ret = LanguageType::FRENCH;
break;
case LANG_ITALIAN:
ret = LanguageType::ITALIAN;
break;
case LANG_GERMAN:
ret = LanguageType::GERMAN;
break;
case LANG_SPANISH:
ret = LanguageType::SPANISH;
break;
case LANG_DUTCH:
ret = LanguageType::DUTCH;
break;
case LANG_RUSSIAN:
ret = LanguageType::RUSSIAN;
break;
case LANG_KOREAN:
ret = LanguageType::KOREAN;
break;
case LANG_JAPANESE:
ret = LanguageType::JAPANESE;
break;
case LANG_HUNGARIAN:
ret = LanguageType::HUNGARIAN;
break;
case LANG_PORTUGUESE:
ret = LanguageType::PORTUGUESE;
break;
case LANG_ARABIC:
ret = LanguageType::ARABIC;
break;
case LANG_NORWEGIAN:
ret = LanguageType::NORWEGIAN;
break;
case LANG_POLISH:
ret = LanguageType::POLISH;
break;
}
return ret;
}
示例3: nulldrv_GetKeyboardLayoutList
static UINT CDECL nulldrv_GetKeyboardLayoutList( INT size, HKL *layouts )
{
HKEY hKeyKeyboard;
DWORD rc;
INT count = 0;
ULONG_PTR baselayout;
LANGID langid;
static const WCHAR szKeyboardReg[] = {'S','y','s','t','e','m','\\','C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\','C','o','n','t','r','o','l','\\','K','e','y','b','o','a','r','d',' ','L','a','y','o','u','t','s',0};
baselayout = GetUserDefaultLCID();
langid = PRIMARYLANGID(LANGIDFROMLCID(baselayout));
if (langid == LANG_CHINESE || langid == LANG_JAPANESE || langid == LANG_KOREAN)
baselayout = MAKELONG( baselayout, 0xe001 ); /* IME */
else
baselayout |= baselayout << 16;
/* Enumerate the Registry */
rc = RegOpenKeyW(HKEY_LOCAL_MACHINE,szKeyboardReg,&hKeyKeyboard);
if (rc == ERROR_SUCCESS)
{
do {
WCHAR szKeyName[9];
HKL layout;
rc = RegEnumKeyW(hKeyKeyboard, count, szKeyName, 9);
if (rc == ERROR_SUCCESS)
{
layout = (HKL)(ULONG_PTR)strtoulW(szKeyName,NULL,16);
if (baselayout != 0 && layout == (HKL)baselayout)
baselayout = 0; /* found in the registry do not add again */
if (size && layouts)
{
if (count >= size ) break;
layouts[count] = layout;
}
count ++;
}
} while (rc == ERROR_SUCCESS);
RegCloseKey(hKeyKeyboard);
}
/* make sure our base layout is on the list */
if (baselayout != 0)
{
if (size && layouts)
{
if (count < size)
{
layouts[count] = (HKL)baselayout;
count++;
}
}
else
count++;
}
return count;
}
示例4: AfxThrowResourceException
BOOL CErrorsDialog::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the help button to be inactive
m_ctlHelp.EnableWindow(FALSE);
// Read in the error information from IErrorRecords
CDBErrorInfo errInfo;
ULONG ulRecords = 0;
HRESULT hr;
hr = errInfo.GetErrorRecords(m_spUnk, m_iid, &ulRecords);
if (FAILED(hr) || hr == S_FALSE || ulRecords == 0)
{
CString strError;
if( strError.LoadString(IDS_NOSPECIFIED_SOURCE) == FALSE)
{
AfxThrowResourceException();
}
m_ctlListSource.AddString(strError);
}
else
{
LCID lcid = GetUserDefaultLCID();
for (ULONG l=0; l<ulRecords; l++)
{
// Get the error information from the source
struct MYERRORINFO* pInfo = new MYERRORINFO;
#pragma warning(disable: 6011) // unexpected null dereference prefast warning
hr = errInfo.GetAllErrorInfo(l, lcid, &pInfo->bstrDescription,
&pInfo->bstrSource, &pInfo->guid, &pInfo->dwHelpContext,
&pInfo->bstrHelpFile);
#pragma warning(default: 6011) // unexpected null dereference prefast warning
if (FAILED(hr))
{
delete pInfo;
continue;
}
m_listErrorInfo.AddTail(pInfo);
// Add the information to the list view
if (pInfo->bstrSource)
m_ctlListSource.AddString(COLE2T(pInfo->bstrSource));
else
m_ctlListSource.AddString(_T("Unspecified error."));
}
}
m_ctlListSource.SetCurSel(0);
SelectSource(0);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
示例5: call_disp_func
static HRESULT call_disp_func(IDispatch *disp, DISPPARAMS *dp, VARIANT *retv)
{
IDispatchEx *dispex;
EXCEPINFO ei;
HRESULT hres;
memset(&ei, 0, sizeof(ei));
hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex);
if(SUCCEEDED(hres)) {
hres = IDispatchEx_InvokeEx(dispex, 0, GetUserDefaultLCID(), DISPATCH_METHOD, dp, retv, &ei, NULL);
IDispatchEx_Release(dispex);
}else {
TRACE("Could not get IDispatchEx interface: %08x\n", hres);
hres = IDispatch_Invoke(disp, 0, &IID_NULL, GetUserDefaultLCID(), DISPATCH_METHOD,
dp, retv, &ei, NULL);
}
return hres;
}
示例6: MCS_getsystemlocale
MCLocaleRef MCS_getsystemlocale()
{
// Get the identifier for the system locale
LCID t_system_lcid;
t_system_lcid = GetUserDefaultLCID();
// Create a locale object
MCLocaleRef t_locale;
/* UNCHECKED */ MCLocaleCreateWithLCID(t_system_lcid, t_locale);
return t_locale;
}
示例7: OnCrystalDewWorld
void CAboutDlg::OnCrystalDewWorld()
{
if(GetUserDefaultLCID() == 0x0411)// Japanese
{
OpenUrl(URL_CRYSTAL_DEW_WORLD_JA);
}
else // Other Language
{
OpenUrl(URL_CRYSTAL_DEW_WORLD_EN);
}
}
示例8: GetAcceptLanguagesW
HRESULT WINAPI GetAcceptLanguagesW(WCHAR *langbuf, DWORD *buflen)
{
static const WCHAR keyW[] = {
'S','o','f','t','w','a','r','e','\\',
'M','i','c','r','o','s','o','f','t','\\',
'I','n','t','e','r','n','e','t',' ','E','x','p','l','o','r','e','r','\\',
'I','n','t','e','r','n','a','t','i','o','n','a','l',0};
static const WCHAR valueW[] = {'A','c','c','e','p','t','L','a','n','g','u','a','g','e',0};
DWORD mystrlen, mytype;
WCHAR *mystr;
LCID mylcid;
HKEY mykey;
LONG lres;
DWORD len;
TRACE("%p, %p, *%p: %d\n", langbuf, buflen, buflen, buflen ? *buflen : -1);
if (!langbuf || !buflen || !*buflen)
return E_FAIL;
mystrlen = (*buflen > 20) ? *buflen : 20 ;
len = mystrlen * sizeof(WCHAR);
mystr = heap_alloc(len);
mystr[0] = 0;
RegOpenKeyW(HKEY_CURRENT_USER, keyW, &mykey);
lres = RegQueryValueExW(mykey, valueW, 0, &mytype, (PBYTE)mystr, &len);
RegCloseKey(mykey);
len = lstrlenW(mystr);
if (!lres && (*buflen > len))
{
lstrcpyW(langbuf, mystr);
*buflen = len;
heap_free(mystr);
return S_OK;
}
/* Did not find a value in the registry or the user buffer is too small */
mylcid = GetUserDefaultLCID();
lcid_to_rfc1766(mylcid, mystr, mystrlen);
len = lstrlenW(mystr);
memcpy(langbuf, mystr, min(*buflen, len + 1)*sizeof(WCHAR));
heap_free(mystr);
if (*buflen > len)
{
*buflen = len;
return S_OK;
}
*buflen = 0;
return E_NOT_SUFFICIENT_BUFFER;
}
示例9: win32_set_locale
/**
*
* Determine and set Grisbi locale as follows (in order of priority):
* - Value of HKCU\SOFTWARE\GRISBI\LANG
* - Value of %LANG% (LANG con content a LOCALE definition or a LCID value)
* - Default user value
*
* @return Does the function change the application context LANG value
* @retval TRUE a value have set to LANG
* @retval FALSE LANG has not been modified for any reason.
*
*/
gboolean win32_set_locale()
{ /* {{{ */
gchar* gzLocale = NULL;
BOOL bFound = FALSE;
// ---------------------------------------------------------------------
// Grisbi language has been configured through the specific application
// ---------------------------------------------------------------------
// 1 - look into HKCU/SOFTWARE/GRISBI/LANG
gzLocale = win32_strdup_registry(HKEY_CURRENT_USER,"SOFTWARE\\GRISBI","LANG",REG_SZ);
bFound = (BOOL)(gzLocale && (*gzLocale));
// ---------------------------------------------------------------------
// Try to find language setting using the LANG environment variable
// ---------------------------------------------------------------------
if(!bFound)
{
g_unsetenv("LANG");
gzLocale = g_getenv("LANG");
bFound = (BOOL)(gzLocale && (*gzLocale));
if (bFound)
{
// LANG can contain the Windows LCID instead of the LC_LOCALE value, in this case we need to convert it
// LANG can the LCID given in decimal
// LANG can the LCID given is hexadecimal
// When LANG is the LCID its size is 3 or 4 and start with a digit
// In other case we suppose LANG to be a valid LC_LOCALE value
int len = strlen(gzLocale);
if ( (len==3||len==4)&&(g_ascii_isdigit(*gzLocale)))
{
gzLocale = win32_lcid_to_lang(atoi(gzLocale));
bFound = (BOOL)(gzLocale && (*gzLocale));
}
}
}
// ---------------------------------------------------------------------
// Last change: retrieve current Windows value
// ---------------------------------------------------------------------
if ( (!bFound) || (!gzLocale) || ( (gzLocale) && (!(*gzLocale)) ) )
{
gzLocale = win32_lcid_to_lang(GetUserDefaultLCID());
}
if ((gzLocale)&&(*gzLocale))
{
bFound = TRUE;
g_setenv("LANG",gzLocale,TRUE);
g_free(gzLocale);
gzLocale = NULL;
}
return bFound;
} /* }}} */
示例10: _A2W_A
TSystemTime::TSystemTime(const tstring& s, LCID locale)
{
_USES_CONVERSION_A;
LPCOLESTR olestr = _A2W_A(s.c_str());
const LCID lcid = locale ? locale : GetUserDefaultLCID();
const ULONG flags = 0;
DATE date;
HRESULT hr = VarDateFromStr(VARDATEFROMSTR_PARAM1(olestr), lcid, flags, &date);
if (hr != S_OK) TXOwl::Raise(IDS_SYSTEMTIMEPARSEFAIL);
int r = VariantTimeToSystemTime(date, this);
if (r == FALSE) TXOwl::Raise(IDS_SYSTEMTIMEPARSEFAIL);
}
示例11: GetUserDefaultLCID
ccLanguageType CCApplication::getCurrentLanguage()
{
ccLanguageType ret = kLanguageEnglish;
LCID localeID = GetUserDefaultLCID();
unsigned short primaryLanguageID = localeID & 0xFF;
switch (primaryLanguageID)
{
case LANG_CHINESE:
ret = kLanguageChinese;
break;
case LANG_ENGLISH:
ret = kLanguageEnglish;
break;
case LANG_FRENCH:
ret = kLanguageFrench;
break;
case LANG_ITALIAN:
ret = kLanguageItalian;
break;
case LANG_GERMAN:
ret = kLanguageGerman;
break;
case LANG_SPANISH:
ret = kLanguageSpanish;
break;
case LANG_DUTCH:
ret = kLanguageDutch;
break;
case LANG_RUSSIAN:
ret = kLanguageRussian;
break;
case LANG_KOREAN:
ret = kLanguageKorean;
break;
case LANG_JAPANESE:
ret = kLanguageJapanese;
break;
case LANG_HUNGARIAN:
ret = kLanguageHungarian;
break;
case LANG_PORTUGUESE:
ret = kLanguagePortuguese;
break;
case LANG_ARABIC:
ret = kLanguageArabic;
break;
}
return ret;
}
示例12: LoadRegTypeLib
HRESULT primLoadRegTypeLib
( GUID* rguid
, short wMaj
, short wMin
, LCID lcid
, void** ppv
)
{
HRESULT hr;
hr = LoadRegTypeLib(rguid, wMaj, wMin, GetUserDefaultLCID(), (IUnknown**)ppv);
return hr;
}
示例13: getLangFromLCID
std::string PATH_INFO::find_translated_file( const std::string &pathid,
const std::string &extension, const std::string &fallbackid )
{
const std::string base_path = FILENAMES[pathid];
#if defined LOCALIZE && ! defined __CYGWIN__
std::string loc_name;
if( get_option<std::string>( "USE_LANG" ).empty() ) {
#if (defined _WIN32 || defined WINDOWS)
loc_name = getLangFromLCID( GetUserDefaultLCID() );
if( !loc_name.empty() ) {
const std::string local_path = base_path + loc_name + extension;
if( file_exist( local_path ) ) {
return local_path;
}
}
#endif
const char *v = setlocale( LC_ALL, NULL );
if( v != NULL ) {
loc_name = v;
}
} else {
loc_name = get_option<std::string>( "USE_LANG" );
}
if( loc_name == "C" ) {
loc_name = "en";
}
if( !loc_name.empty() ) {
const size_t dotpos = loc_name.find( '.' );
if( dotpos != std::string::npos ) {
loc_name.erase( dotpos );
}
// complete locale: en_NZ
const std::string local_path = base_path + loc_name + extension;
if( file_exist( local_path ) ) {
return local_path;
}
const size_t p = loc_name.find( '_' );
if( p != std::string::npos ) {
// only the first part: en
const std::string local_path = base_path + loc_name.substr( 0, p ) + extension;
if( file_exist( local_path ) ) {
return local_path;
}
}
}
#endif
(void) extension;
return FILENAMES[fallbackid];
}
示例14: getLocale
std::string getLocale()
{
TCHAR szBuff1[10], szBuff2[10];
LCID lcid = GetUserDefaultLCID();
GetLocaleInfo(lcid, LOCALE_SISO639LANGNAME, szBuff1, 10);
GetLocaleInfo(lcid, LOCALE_SISO3166CTRYNAME, szBuff2, 10);
strcat(szBuff1,"_");
strcat(szBuff1,szBuff2);
return szBuff1;
}
示例15: VERIFY
void CWordPadApp::LoadOptions()
{
BYTE* pb = NULL;
UINT nLen = 0;
HFONT hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
if (hFont == NULL)
hFont = (HFONT)GetStockObject(ANSI_VAR_FONT);
VERIFY(::GetObject(hFont, sizeof(LOGFONT), &m_lf));
m_bWordSel = GetProfileInt(szSection, szWordSel, TRUE);
TCHAR buf[2];
buf[0] = NULL;
GetLocaleInfo(GetUserDefaultLCID(), LOCALE_IMEASURE, buf, 2);
int nDefUnits = buf[0] == '1' ? 0 : 1;
SetUnits(GetProfileInt(szSection, szUnits, nDefUnits));
m_bMaximized = GetProfileInt(szSection, szMaximized, (int)FALSE);
if (GetProfileBinary(szSection, szFrameRect, &pb, &nLen))
{
ASSERT(nLen == sizeof(CRect));
memcpy(&m_rectInitialFrame, pb, sizeof(CRect));
delete pb;
}
else
m_rectInitialFrame.SetRect(0,0,0,0);
CRect rectScreen(0, 0, GetSystemMetrics(SM_CXSCREEN),
GetSystemMetrics(SM_CYSCREEN));
CRect rectInt;
rectInt.IntersectRect(&rectScreen, &m_rectInitialFrame);
if (rectInt.Width() < 10 || rectInt.Height() < 10)
m_rectInitialFrame.SetRect(0, 0, 0, 0);
if (GetProfileBinary(szSection, szPageMargin, &pb, &nLen))
{
ASSERT(nLen == sizeof(CRect));
memcpy(&m_rectPageMargin, pb, sizeof(CRect));
delete pb;
}
else
m_rectPageMargin.SetRect(1800, 1440, 1800, 1440);
m_optionsText.LoadOptions(szTextSection);
m_optionsRTF.LoadOptions(szRTFSection);
m_optionsWord.LoadOptions(szWordSection);
m_optionsWrite.LoadOptions(szWriteSection);
m_optionsIP.LoadOptions(szIPSection);
}