1*f8e2c85aSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*f8e2c85aSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*f8e2c85aSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*f8e2c85aSAndrew Rist * distributed with this work for additional information 6*f8e2c85aSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*f8e2c85aSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*f8e2c85aSAndrew Rist * "License"); you may not use this file except in compliance 9*f8e2c85aSAndrew Rist * with the License. You may obtain a copy of the License at 10*f8e2c85aSAndrew Rist * 11*f8e2c85aSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*f8e2c85aSAndrew Rist * 13*f8e2c85aSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*f8e2c85aSAndrew Rist * software distributed under the License is distributed on an 15*f8e2c85aSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*f8e2c85aSAndrew Rist * KIND, either express or implied. See the License for the 17*f8e2c85aSAndrew Rist * specific language governing permissions and limitations 18*f8e2c85aSAndrew Rist * under the License. 19*f8e2c85aSAndrew Rist * 20*f8e2c85aSAndrew Rist *************************************************************/ 21*f8e2c85aSAndrew Rist 22*f8e2c85aSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_shell.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir 28cdf0e10cSrcweir #include "internal/config.hxx" 29cdf0e10cSrcweir #include "internal/dbgmacros.hxx" 30cdf0e10cSrcweir #include "internal/utilities.hxx" 31cdf0e10cSrcweir 32cdf0e10cSrcweir //----------------------------- 33cdf0e10cSrcweir // constants 34cdf0e10cSrcweir //----------------------------- 35cdf0e10cSrcweir 36cdf0e10cSrcweir const size_t MAX_RES_STRING = 1024; 37cdf0e10cSrcweir const wchar_t SPACE_CHAR = _T(' '); 38cdf0e10cSrcweir 39cdf0e10cSrcweir //--------------------------------- 40cdf0e10cSrcweir /** 41cdf0e10cSrcweir */ 42cdf0e10cSrcweir std::wstring StringToWString(const std::string& String) 43cdf0e10cSrcweir { 44cdf0e10cSrcweir int len = MultiByteToWideChar( 45cdf0e10cSrcweir CP_ACP, 0, String.c_str(), -1, 0, 0); 46cdf0e10cSrcweir 47cdf0e10cSrcweir wchar_t* buff = reinterpret_cast<wchar_t*>( 48cdf0e10cSrcweir _alloca(len * sizeof(wchar_t))); 49cdf0e10cSrcweir 50cdf0e10cSrcweir MultiByteToWideChar( 51cdf0e10cSrcweir CP_ACP, 0, String.c_str(), -1, buff, len); 52cdf0e10cSrcweir 53cdf0e10cSrcweir return std::wstring(buff); 54cdf0e10cSrcweir } 55cdf0e10cSrcweir 56cdf0e10cSrcweir //--------------------------------- 57cdf0e10cSrcweir /** 58cdf0e10cSrcweir */ 59cdf0e10cSrcweir std::string WStringToString(const std::wstring& String) 60cdf0e10cSrcweir { 61cdf0e10cSrcweir int len = WideCharToMultiByte( 62cdf0e10cSrcweir CP_ACP, 0, String.c_str(), -1, 0, 0, 0, 0); 63cdf0e10cSrcweir 64cdf0e10cSrcweir char* buff = reinterpret_cast<char*>( 65cdf0e10cSrcweir _alloca(len * sizeof(char))); 66cdf0e10cSrcweir 67cdf0e10cSrcweir WideCharToMultiByte( 68cdf0e10cSrcweir CP_ACP, 0, String.c_str(), -1, buff, len, 0, 0); 69cdf0e10cSrcweir 70cdf0e10cSrcweir return std::string(buff); 71cdf0e10cSrcweir } 72cdf0e10cSrcweir 73cdf0e10cSrcweir //--------------------------------- 74cdf0e10cSrcweir /** 75cdf0e10cSrcweir */ 76cdf0e10cSrcweir std::wstring GetResString(int ResId) 77cdf0e10cSrcweir { 78cdf0e10cSrcweir wchar_t szResStr[MAX_RES_STRING]; 79cdf0e10cSrcweir 80cdf0e10cSrcweir int rc = LoadStringW( GetModuleHandleW(MODULE_NAME), ResId, szResStr, sizeof(szResStr) ); 81cdf0e10cSrcweir 82cdf0e10cSrcweir OutputDebugStringFormat( "GetResString: read %d chars\n", rc ); 83cdf0e10cSrcweir ENSURE(rc, "String resource not found"); 84cdf0e10cSrcweir 85cdf0e10cSrcweir return std::wstring(szResStr); 86cdf0e10cSrcweir } 87cdf0e10cSrcweir 88cdf0e10cSrcweir //--------------------------------- 89cdf0e10cSrcweir /** 90cdf0e10cSrcweir */ 91cdf0e10cSrcweir bool is_windows_xp_or_above() 92cdf0e10cSrcweir { 93cdf0e10cSrcweir OSVERSIONINFO osvi; 94cdf0e10cSrcweir ZeroMemory(&osvi, sizeof(osvi)); 95cdf0e10cSrcweir osvi.dwOSVersionInfoSize = sizeof(osvi); 96cdf0e10cSrcweir GetVersionEx(&osvi); 97cdf0e10cSrcweir 98cdf0e10cSrcweir // LLA: check for windows xp or above (Vista) 99cdf0e10cSrcweir if (osvi.dwMajorVersion > 5 || 100cdf0e10cSrcweir (5 == osvi.dwMajorVersion && osvi.dwMinorVersion >= 1)) 101cdf0e10cSrcweir { 102cdf0e10cSrcweir return true; 103cdf0e10cSrcweir } 104cdf0e10cSrcweir return false; 105cdf0e10cSrcweir } 106cdf0e10cSrcweir 107cdf0e10cSrcweir //--------------------------------- 108cdf0e10cSrcweir /** 109cdf0e10cSrcweir */ 110cdf0e10cSrcweir 111cdf0e10cSrcweir void SaveDebugInfoToFile( const std::wstring& str ) 112cdf0e10cSrcweir { 113cdf0e10cSrcweir int handle; 114cdf0e10cSrcweir 115cdf0e10cSrcweir if ((handle = open("c:\\temp\\SHELLRESULT.$$$", O_CREAT | O_RDWR | O_APPEND )) == -1) 116cdf0e10cSrcweir { 117cdf0e10cSrcweir perror("Error: open file error"); 118cdf0e10cSrcweir return; 119cdf0e10cSrcweir } 120cdf0e10cSrcweir write(handle, str.c_str(), str.length() ); 121cdf0e10cSrcweir close(handle); 122cdf0e10cSrcweir } 123cdf0e10cSrcweir 124cdf0e10cSrcweir //--------------------------------- 125cdf0e10cSrcweir /** helper function to judge if the string is only has spaces. 126cdf0e10cSrcweir @returns 127cdf0e10cSrcweir <TRUE>if the provided string contains only but at least one space 128cdf0e10cSrcweir character else <FALSE/>. 129cdf0e10cSrcweir */ 130cdf0e10cSrcweir 131cdf0e10cSrcweir bool HasOnlySpaces(const std::wstring& String) 132cdf0e10cSrcweir { 133cdf0e10cSrcweir if ( String.length() == 0 ) 134cdf0e10cSrcweir return false; 135cdf0e10cSrcweir 136cdf0e10cSrcweir const wchar_t* p = String.c_str(); 137cdf0e10cSrcweir 138cdf0e10cSrcweir while (*p) 139cdf0e10cSrcweir { 140cdf0e10cSrcweir if (*p++ != SPACE_CHAR) 141cdf0e10cSrcweir return false; 142cdf0e10cSrcweir } 143cdf0e10cSrcweir 144cdf0e10cSrcweir return true; 145cdf0e10cSrcweir } 146cdf0e10cSrcweir 147cdf0e10cSrcweir //--------------------------------- 148cdf0e10cSrcweir /** helper function to convert windows pathes to short form. 149cdf0e10cSrcweir @returns 150cdf0e10cSrcweir shortend path. 151cdf0e10cSrcweir */ 152cdf0e10cSrcweir 153cdf0e10cSrcweir std::wstring getShortPathName( const std::wstring& aLongName ) 154cdf0e10cSrcweir { 155cdf0e10cSrcweir std::wstring shortName = aLongName; 156cdf0e10cSrcweir long length = GetShortPathName( aLongName.c_str(), NULL, 0 ); 157cdf0e10cSrcweir 158cdf0e10cSrcweir if ( length != 0 ) 159cdf0e10cSrcweir { 160cdf0e10cSrcweir TCHAR* buffer = new TCHAR[ length+1 ]; 161cdf0e10cSrcweir length = GetShortPathName( aLongName.c_str(), buffer, length ); 162cdf0e10cSrcweir if ( length != 0 ) 163cdf0e10cSrcweir shortName = std::wstring( buffer ); 164cdf0e10cSrcweir delete [] buffer; 165cdf0e10cSrcweir } 166cdf0e10cSrcweir return shortName; 167cdf0e10cSrcweir } 168cdf0e10cSrcweir 169cdf0e10cSrcweir /** convert LocaleSet pair into Microsoft List of Locale ID (LCID) 170cdf0e10cSrcweir according to ISO-639 and ISO-3166. 171cdf0e10cSrcweir http://etext.lib.virginia.edu/tei/iso639.html 172cdf0e10cSrcweir http://nl.ijs.si/gnusl/cee/std/ISO_3166.html 173cdf0e10cSrcweir @param 174cdf0e10cSrcweir Locale, LocaleSet 175cdf0e10cSrcweir @returns 176cdf0e10cSrcweir Windows Locale Identifier corresponding to input LocaleSet. 177cdf0e10cSrcweir @Usage Sample 178cdf0e10cSrcweir LocaleSet_t myDefaultLocale( ::std::wstring( L"zh" ),::std::wstring(L"HK") ); 179cdf0e10cSrcweir DWORD myLCID = LocaleSetToLCID( myDefaultLocale ); 180cdf0e10cSrcweir wchar_t buffer[20]; 181cdf0e10cSrcweir _ultow( myLCID, buffer, 16 ); 182cdf0e10cSrcweir MessageBox( NULL, buffer,L"the LCID is:",MB_OK ); 183cdf0e10cSrcweir */ 184cdf0e10cSrcweir 185cdf0e10cSrcweir LCID LocaleSetToLCID( const LocaleSet_t & Locale ) 186cdf0e10cSrcweir { 187cdf0e10cSrcweir if ( EMPTY_LOCALE == Locale ) 188cdf0e10cSrcweir return GetSystemDefaultLCID(); 189cdf0e10cSrcweir 190cdf0e10cSrcweir USHORT usPrimaryLang= LANG_NEUTRAL; 191cdf0e10cSrcweir USHORT usSubLang=SUBLANG_DEFAULT; 192cdf0e10cSrcweir 193cdf0e10cSrcweir ::std::wstring wsLanguage(Locale.first); 194cdf0e10cSrcweir ::std::wstring wsCountry(Locale.second); 195cdf0e10cSrcweir 196cdf0e10cSrcweir if ( wsLanguage == L"ar" ) 197cdf0e10cSrcweir { 198cdf0e10cSrcweir usPrimaryLang = LANG_ARABIC; // Arabic 01 199cdf0e10cSrcweir 200cdf0e10cSrcweir if ( wsCountry == L"SA" ) 201cdf0e10cSrcweir usSubLang = SUBLANG_ARABIC_SAUDI_ARABIA; // Arabic (Saudi Arabia) 202cdf0e10cSrcweir else if ( wsCountry == L"IQ" ) 203cdf0e10cSrcweir usSubLang = SUBLANG_ARABIC_IRAQ; // Arabic (Iraq) 204cdf0e10cSrcweir else if ( wsCountry == L"EG" ) 205cdf0e10cSrcweir usSubLang = SUBLANG_ARABIC_EGYPT; // Arabic (Egypt) 206cdf0e10cSrcweir else if ( wsCountry == L"LY" ) 207cdf0e10cSrcweir usSubLang = SUBLANG_ARABIC_LIBYA; // Arabic (Libya) 208cdf0e10cSrcweir else if ( wsCountry == L"DZ" ) 209cdf0e10cSrcweir usSubLang = SUBLANG_ARABIC_ALGERIA; // Arabic (Algeria) 210cdf0e10cSrcweir else if ( wsCountry == L"MA" ) 211cdf0e10cSrcweir usSubLang = SUBLANG_ARABIC_MOROCCO; // Arabic (Morocco) 212cdf0e10cSrcweir else if ( wsCountry == L"TN" ) 213cdf0e10cSrcweir usSubLang = SUBLANG_ARABIC_TUNISIA; // Arabic (Tunisia) 214cdf0e10cSrcweir else if ( wsCountry == L"OM" ) 215cdf0e10cSrcweir usSubLang = SUBLANG_ARABIC_OMAN; // Arabic (Oman) 216cdf0e10cSrcweir else if ( wsCountry == L"YE" ) 217cdf0e10cSrcweir usSubLang = SUBLANG_ARABIC_YEMEN; // Arabic (Yemen) 218cdf0e10cSrcweir else if ( wsCountry == L"SY" ) 219cdf0e10cSrcweir usSubLang = SUBLANG_ARABIC_SYRIA; // Arabic (Syria) 220cdf0e10cSrcweir else if ( wsCountry == L"JO" ) 221cdf0e10cSrcweir usSubLang = SUBLANG_ARABIC_JORDAN; // Arabic (Jordan) 222cdf0e10cSrcweir else if ( wsCountry == L"LB" ) 223cdf0e10cSrcweir usSubLang = SUBLANG_ARABIC_LEBANON; // Arabic (Lebanon) 224cdf0e10cSrcweir else if ( wsCountry == L"KW" ) 225cdf0e10cSrcweir usSubLang = SUBLANG_ARABIC_KUWAIT; // Arabic (Kuwait) 226cdf0e10cSrcweir else if ( wsCountry == L"AE" ) 227cdf0e10cSrcweir usSubLang = SUBLANG_ARABIC_UAE; // Arabic (U.A.E.) 228cdf0e10cSrcweir else if ( wsCountry == L"BH" ) 229cdf0e10cSrcweir usSubLang = SUBLANG_ARABIC_BAHRAIN; // Arabic (Bahrain) 230cdf0e10cSrcweir else if ( wsCountry == L"QA" ) 231cdf0e10cSrcweir usSubLang = SUBLANG_ARABIC_QATAR; // Arabic (Qatar) 232cdf0e10cSrcweir else 233cdf0e10cSrcweir usSubLang = SUBLANG_DEFAULT; //default sub language 234cdf0e10cSrcweir } 235cdf0e10cSrcweir else if ( wsLanguage == L"bg" ) 236cdf0e10cSrcweir usPrimaryLang = LANG_BULGARIAN; //Bulgarian 02 237cdf0e10cSrcweir else if ( wsLanguage == L"ca" ) 238cdf0e10cSrcweir usPrimaryLang = LANG_CATALAN; //Catalan 03 239cdf0e10cSrcweir else if ( wsLanguage == L"zh" ) 240cdf0e10cSrcweir { 241cdf0e10cSrcweir usPrimaryLang = LANG_CHINESE; //Chinese 242cdf0e10cSrcweir if ( wsCountry == L"TW" ) 243cdf0e10cSrcweir usSubLang = SUBLANG_CHINESE_TRADITIONAL; // Chinese (Traditional) 244cdf0e10cSrcweir else if ( wsCountry == L"CN" ) 245cdf0e10cSrcweir usSubLang = SUBLANG_CHINESE_SIMPLIFIED; // Chinese (Simplified) 246cdf0e10cSrcweir else if ( wsCountry == L"HK" ) 247cdf0e10cSrcweir usSubLang = SUBLANG_CHINESE_HONGKONG; // Chinese (Hong Kong SAR, PRC) 248cdf0e10cSrcweir else if ( wsCountry == L"SG" ) 249cdf0e10cSrcweir usSubLang = SUBLANG_CHINESE_SINGAPORE; // Chinese (Singapore) 250cdf0e10cSrcweir else if ( wsCountry == L"MO" ) 251cdf0e10cSrcweir usSubLang = SUBLANG_CHINESE_MACAU; // Chinese (Macau SAR) 252cdf0e10cSrcweir else 253cdf0e10cSrcweir usSubLang = SUBLANG_DEFAULT; //default sub language 254cdf0e10cSrcweir } 255cdf0e10cSrcweir else if ( wsLanguage == L"cs" ) 256cdf0e10cSrcweir usPrimaryLang = LANG_CZECH; //Czech 257cdf0e10cSrcweir else if ( wsLanguage == L"da" ) 258cdf0e10cSrcweir usPrimaryLang = LANG_DANISH; //Danish 259cdf0e10cSrcweir else if ( wsLanguage == L"de" ) 260cdf0e10cSrcweir { 261cdf0e10cSrcweir usPrimaryLang = LANG_GERMAN; //German 262cdf0e10cSrcweir if ( wsCountry == L"DE" ) 263cdf0e10cSrcweir usSubLang = SUBLANG_GERMAN; // German 264cdf0e10cSrcweir else if ( wsCountry == L"CH" ) 265cdf0e10cSrcweir usSubLang = SUBLANG_GERMAN_SWISS; // German (Swiss) 266cdf0e10cSrcweir else if ( wsCountry == L"AT" ) 267cdf0e10cSrcweir usSubLang = SUBLANG_GERMAN_AUSTRIAN; // German (Austrian) 268cdf0e10cSrcweir else if ( wsCountry == L"LU" ) 269cdf0e10cSrcweir usSubLang = SUBLANG_GERMAN_LUXEMBOURG; // German (Luxembourg) 270cdf0e10cSrcweir else if ( wsCountry == L"LI" ) 271cdf0e10cSrcweir usSubLang = SUBLANG_GERMAN_LIECHTENSTEIN; // German (Liechtenstein) 272cdf0e10cSrcweir else 273cdf0e10cSrcweir usSubLang = SUBLANG_DEFAULT; //default sub language 274cdf0e10cSrcweir } 275cdf0e10cSrcweir else if ( wsLanguage == L"el" ) 276cdf0e10cSrcweir usPrimaryLang = LANG_GREEK; //Greek 277cdf0e10cSrcweir else if ( wsLanguage == L"en" ) 278cdf0e10cSrcweir { 279cdf0e10cSrcweir usPrimaryLang = LANG_ENGLISH; //English 280cdf0e10cSrcweir if ( wsCountry == L"US" ) 281cdf0e10cSrcweir usSubLang = SUBLANG_ENGLISH_US; // English (US) 282cdf0e10cSrcweir else if ( wsCountry == L"GB" ) 283cdf0e10cSrcweir usSubLang = SUBLANG_ENGLISH_UK; // English (UK) 284cdf0e10cSrcweir else if ( wsCountry == L"AU" ) 285cdf0e10cSrcweir usSubLang = SUBLANG_ENGLISH_AUS; // English (Australian) 286cdf0e10cSrcweir else if ( wsCountry == L"CA" ) 287cdf0e10cSrcweir usSubLang = SUBLANG_ENGLISH_CAN; // English (Canadian) 288cdf0e10cSrcweir else if ( wsCountry == L"NZ" ) 289cdf0e10cSrcweir usSubLang = SUBLANG_ENGLISH_NZ; // English (New Zealand) 290cdf0e10cSrcweir else if ( wsCountry == L"IE" ) 291cdf0e10cSrcweir usSubLang = SUBLANG_ENGLISH_EIRE; // English (Ireland) 292cdf0e10cSrcweir else if ( wsCountry == L"ZA" ) 293cdf0e10cSrcweir usSubLang = SUBLANG_ENGLISH_SOUTH_AFRICA; // English (South Africa) 294cdf0e10cSrcweir else if ( wsCountry == L"JM" ) 295cdf0e10cSrcweir usSubLang = SUBLANG_ENGLISH_JAMAICA; // English (Jamaica) 296cdf0e10cSrcweir else if ( wsCountry == L"GD" ) 297cdf0e10cSrcweir usSubLang = SUBLANG_ENGLISH_CARIBBEAN; // English (Caribbean) Grenada 298cdf0e10cSrcweir else if ( wsCountry == L"BZ" ) 299cdf0e10cSrcweir usSubLang = SUBLANG_ENGLISH_BELIZE; // English (Belize) 300cdf0e10cSrcweir else if ( wsCountry == L"TT" ) 301cdf0e10cSrcweir usSubLang = SUBLANG_ENGLISH_TRINIDAD; // English (Trinidad) 302cdf0e10cSrcweir else if ( wsCountry == L"ZW" ) 303cdf0e10cSrcweir usSubLang = SUBLANG_ENGLISH_ZIMBABWE; // English (Zimbabwe) 304cdf0e10cSrcweir else if ( wsCountry == L"PH" ) 305cdf0e10cSrcweir usSubLang = SUBLANG_ENGLISH_PHILIPPINES; // English (Philippines) 306cdf0e10cSrcweir else 307cdf0e10cSrcweir usSubLang = SUBLANG_DEFAULT; //default sub language 308cdf0e10cSrcweir } 309cdf0e10cSrcweir else if ( wsLanguage == L"es" ) 310cdf0e10cSrcweir { 311cdf0e10cSrcweir usPrimaryLang = LANG_SPANISH; //Spanish 312cdf0e10cSrcweir //else if ( wsCountry == L"ES" ) 313cdf0e10cSrcweir // usSubLang = SUBLANG_SPANISH; // Spanish (Castilian) 314cdf0e10cSrcweir if ( wsCountry == L"MX" ) 315cdf0e10cSrcweir usSubLang = SUBLANG_SPANISH_MEXICAN; // Spanish (Mexican) 316cdf0e10cSrcweir else if ( wsCountry == L"ES" ) 317cdf0e10cSrcweir usSubLang = SUBLANG_SPANISH_MODERN; // Spanish (Spain) 318cdf0e10cSrcweir else if ( wsCountry == L"GT" ) 319cdf0e10cSrcweir usSubLang = SUBLANG_SPANISH_GUATEMALA; // Spanish (Guatemala) 320cdf0e10cSrcweir else if ( wsCountry == L"CR" ) 321cdf0e10cSrcweir usSubLang = SUBLANG_SPANISH_COSTA_RICA; // Spanish (Costa Rica) 322cdf0e10cSrcweir else if ( wsCountry == L"PA" ) 323cdf0e10cSrcweir usSubLang = SUBLANG_SPANISH_PANAMA; // Spanish (Panama) 324cdf0e10cSrcweir else if ( wsCountry == L"DO" ) 325cdf0e10cSrcweir usSubLang = SUBLANG_SPANISH_DOMINICAN_REPUBLIC; // Spanish (Dominican Republic) 326cdf0e10cSrcweir else if ( wsCountry == L"VE" ) 327cdf0e10cSrcweir usSubLang = SUBLANG_SPANISH_VENEZUELA; // Spanish (Venezuela) 328cdf0e10cSrcweir else if ( wsCountry == L"CO" ) 329cdf0e10cSrcweir usSubLang = SUBLANG_SPANISH_COLOMBIA; // Spanish (Colombia) 330cdf0e10cSrcweir else if ( wsCountry == L"PE" ) 331cdf0e10cSrcweir usSubLang = SUBLANG_SPANISH_PERU; // Spanish (Peru) 332cdf0e10cSrcweir else if ( wsCountry == L"AR" ) 333cdf0e10cSrcweir usSubLang = SUBLANG_SPANISH_ARGENTINA; // Spanish (Argentina) 334cdf0e10cSrcweir else if ( wsCountry == L"EC" ) 335cdf0e10cSrcweir usSubLang = SUBLANG_SPANISH_ECUADOR; // Spanish (Ecuador) 336cdf0e10cSrcweir else if ( wsCountry == L"CL" ) 337cdf0e10cSrcweir usSubLang = SUBLANG_SPANISH_CHILE; // Spanish (Chile) 338cdf0e10cSrcweir else if ( wsCountry == L"UY" ) 339cdf0e10cSrcweir usSubLang = SUBLANG_SPANISH_URUGUAY; // Spanish (Uruguay) 340cdf0e10cSrcweir else if ( wsCountry == L"PY" ) 341cdf0e10cSrcweir usSubLang = SUBLANG_SPANISH_PARAGUAY; // Spanish (Paraguay) 342cdf0e10cSrcweir else if ( wsCountry == L"BO" ) 343cdf0e10cSrcweir usSubLang = SUBLANG_SPANISH_BOLIVIA; // Spanish (Bolivia) 344cdf0e10cSrcweir else if ( wsCountry == L"SV" ) 345cdf0e10cSrcweir usSubLang = SUBLANG_SPANISH_EL_SALVADOR; // Spanish (El Salvador) 346cdf0e10cSrcweir else if ( wsCountry == L"HN" ) 347cdf0e10cSrcweir usSubLang = SUBLANG_SPANISH_HONDURAS; // Spanish (Honduras) 348cdf0e10cSrcweir else if ( wsCountry == L"NI" ) 349cdf0e10cSrcweir usSubLang = SUBLANG_SPANISH_NICARAGUA; // Spanish (Nicaragua) 350cdf0e10cSrcweir else if ( wsCountry == L"PR" ) 351cdf0e10cSrcweir usSubLang = SUBLANG_SPANISH_PUERTO_RICO; // Spanish (Puerto Rico) 352cdf0e10cSrcweir else 353cdf0e10cSrcweir usSubLang = SUBLANG_DEFAULT; //default sub language 354cdf0e10cSrcweir } 355cdf0e10cSrcweir else if ( wsLanguage == L"fi" ) 356cdf0e10cSrcweir usPrimaryLang = LANG_FINNISH; //Finnish 357cdf0e10cSrcweir else if ( wsLanguage == L"fr" ) 358cdf0e10cSrcweir { 359cdf0e10cSrcweir usPrimaryLang = LANG_FRENCH; //French 360cdf0e10cSrcweir if ( wsCountry == L"FR" ) 361cdf0e10cSrcweir usSubLang = SUBLANG_FRENCH; // French 362cdf0e10cSrcweir else if ( wsCountry == L"BE" ) 363cdf0e10cSrcweir usSubLang = SUBLANG_FRENCH_BELGIAN; // French (Belgian) 364cdf0e10cSrcweir else if ( wsCountry == L"CA" ) 365cdf0e10cSrcweir usSubLang = SUBLANG_FRENCH_CANADIAN; // French (Canadian) 366cdf0e10cSrcweir else if ( wsCountry == L"CH" ) 367cdf0e10cSrcweir usSubLang = SUBLANG_FRENCH_SWISS; // French (Swiss) 368cdf0e10cSrcweir else if ( wsCountry == L"LU" ) 369cdf0e10cSrcweir usSubLang = SUBLANG_FRENCH_LUXEMBOURG; // French (Luxembourg) 370cdf0e10cSrcweir else if ( wsCountry == L"MC" ) 371cdf0e10cSrcweir usSubLang = SUBLANG_FRENCH_MONACO; // French (Monaco) 372cdf0e10cSrcweir else 373cdf0e10cSrcweir usSubLang = SUBLANG_DEFAULT; //default sub language 374cdf0e10cSrcweir } 375cdf0e10cSrcweir else if ( wsLanguage == L"iw" ) 376cdf0e10cSrcweir usPrimaryLang = LANG_HEBREW; //Hebrew 377cdf0e10cSrcweir else if ( wsLanguage == L"hu" ) 378cdf0e10cSrcweir usPrimaryLang = LANG_HUNGARIAN; //Hungarian 379cdf0e10cSrcweir else if ( wsLanguage == L"is" ) 380cdf0e10cSrcweir usPrimaryLang = LANG_ICELANDIC; //Icelandic 381cdf0e10cSrcweir else if ( wsLanguage == L"it" ) 382cdf0e10cSrcweir { 383cdf0e10cSrcweir usPrimaryLang = LANG_ITALIAN; //Italian 384cdf0e10cSrcweir if ( wsCountry == L"IT" ) 385cdf0e10cSrcweir usSubLang = SUBLANG_ITALIAN; // Italian 386cdf0e10cSrcweir else if ( wsCountry == L"CH" ) 387cdf0e10cSrcweir usSubLang = SUBLANG_ITALIAN_SWISS; // Italian (Swiss) 388cdf0e10cSrcweir else 389cdf0e10cSrcweir usSubLang = SUBLANG_DEFAULT; //default sub language 390cdf0e10cSrcweir } 391cdf0e10cSrcweir else if ( wsLanguage == L"ja" ) 392cdf0e10cSrcweir usPrimaryLang = LANG_JAPANESE; //Japanese 393cdf0e10cSrcweir else if ( wsLanguage == L"ko" ) 394cdf0e10cSrcweir { 395cdf0e10cSrcweir usPrimaryLang = LANG_KOREAN; //Korean 396cdf0e10cSrcweir if ( wsCountry == L"KR" ) 397cdf0e10cSrcweir usSubLang = SUBLANG_KOREAN; // Korean 398cdf0e10cSrcweir else 399cdf0e10cSrcweir usSubLang = SUBLANG_DEFAULT; //default sub language 400cdf0e10cSrcweir } 401cdf0e10cSrcweir else if ( wsLanguage == L"nl" ) 402cdf0e10cSrcweir { 403cdf0e10cSrcweir usPrimaryLang = LANG_DUTCH; //Dutch 404cdf0e10cSrcweir if ( wsCountry == L"NL" ) 405cdf0e10cSrcweir usSubLang = SUBLANG_DUTCH; // Dutch 406cdf0e10cSrcweir else if ( wsCountry == L"BE" ) 407cdf0e10cSrcweir usSubLang = SUBLANG_DUTCH_BELGIAN; // Dutch (Belgian) 408cdf0e10cSrcweir else 409cdf0e10cSrcweir usSubLang = SUBLANG_DEFAULT; //default sub language 410cdf0e10cSrcweir } 411cdf0e10cSrcweir else if ( wsLanguage == L"no" ) 412cdf0e10cSrcweir { 413cdf0e10cSrcweir usPrimaryLang = LANG_NORWEGIAN; //Norwegian 414cdf0e10cSrcweir if ( wsCountry == L"NO" ) 415cdf0e10cSrcweir usSubLang = SUBLANG_NORWEGIAN_BOKMAL; // Norwegian (Bokmal) 416cdf0e10cSrcweir //else if ( wsCountry == L"NO" ) 417cdf0e10cSrcweir // usSubLang = SUBLANG_NORWEGIAN_NYNORSK; // Norwegian (Nynorsk) 418cdf0e10cSrcweir else 419cdf0e10cSrcweir usSubLang = SUBLANG_DEFAULT; //default sub language 420cdf0e10cSrcweir } 421cdf0e10cSrcweir else if ( wsLanguage == L"pl" ) 422cdf0e10cSrcweir usPrimaryLang = LANG_POLISH; //Polish 423cdf0e10cSrcweir else if ( wsLanguage == L"pt" ) 424cdf0e10cSrcweir { 425cdf0e10cSrcweir usPrimaryLang = LANG_PORTUGUESE; //Portuguese 426cdf0e10cSrcweir if ( wsCountry == L"BR" ) 427cdf0e10cSrcweir usSubLang = SUBLANG_PORTUGUESE_BRAZILIAN; // Portuguese (Brazil) 428cdf0e10cSrcweir else if ( wsCountry == L"PT" ) 429cdf0e10cSrcweir usSubLang = SUBLANG_PORTUGUESE; // Portuguese (Portugal) 430cdf0e10cSrcweir else 431cdf0e10cSrcweir usSubLang = SUBLANG_DEFAULT; //default sub language 432cdf0e10cSrcweir } 433cdf0e10cSrcweir else if ( wsLanguage == L"ro" ) 434cdf0e10cSrcweir usPrimaryLang = LANG_ROMANIAN; //Romanian 435cdf0e10cSrcweir else if ( wsLanguage == L"ru" ) 436cdf0e10cSrcweir usPrimaryLang = LANG_RUSSIAN; //Russian 437cdf0e10cSrcweir else if ( wsLanguage == L"hr" ) 438cdf0e10cSrcweir usPrimaryLang = LANG_CROATIAN; //Croatian 439cdf0e10cSrcweir else if ( wsLanguage == L"sr" ) 440cdf0e10cSrcweir { 441cdf0e10cSrcweir usPrimaryLang = LANG_SERBIAN; //Serbian 442cdf0e10cSrcweir if ( wsCountry == L"VA" ) 443cdf0e10cSrcweir usSubLang = SUBLANG_SERBIAN_LATIN; // Serbian (Latin) 444cdf0e10cSrcweir else if ( wsCountry == L"HR" ) 445cdf0e10cSrcweir usSubLang = SUBLANG_SERBIAN_CYRILLIC; // Serbian (Cyrillic) 446cdf0e10cSrcweir else 447cdf0e10cSrcweir usSubLang = SUBLANG_DEFAULT; //default sub language 448cdf0e10cSrcweir } 449cdf0e10cSrcweir else if ( wsLanguage == L"sk" ) 450cdf0e10cSrcweir usPrimaryLang = LANG_SLOVAK; //Slovak 451cdf0e10cSrcweir else if ( wsLanguage == L"sq" ) 452cdf0e10cSrcweir usPrimaryLang = LANG_ALBANIAN; //Albanian 453cdf0e10cSrcweir else if ( wsLanguage == L"sv" ) 454cdf0e10cSrcweir { 455cdf0e10cSrcweir usPrimaryLang = LANG_SWEDISH; //Swedish 456cdf0e10cSrcweir if ( wsCountry == L"SE" ) 457cdf0e10cSrcweir usSubLang = SUBLANG_SWEDISH; // Swedish 458cdf0e10cSrcweir else if ( wsCountry == L"FI" ) 459cdf0e10cSrcweir usSubLang = SUBLANG_SWEDISH_FINLAND; // Swedish (Finland) 460cdf0e10cSrcweir else 461cdf0e10cSrcweir usSubLang = SUBLANG_DEFAULT; //default sub language 462cdf0e10cSrcweir } 463cdf0e10cSrcweir else if ( wsLanguage == L"th" ) 464cdf0e10cSrcweir usPrimaryLang = LANG_THAI; //Thai 465cdf0e10cSrcweir else if ( wsLanguage == L"tr" ) 466cdf0e10cSrcweir usPrimaryLang = LANG_TURKISH; //Turkish 467cdf0e10cSrcweir else if ( wsLanguage == L"ur" ) 468cdf0e10cSrcweir { 469cdf0e10cSrcweir usPrimaryLang = LANG_URDU; //Urdu 470cdf0e10cSrcweir if ( wsCountry == L"PK" ) 471cdf0e10cSrcweir usSubLang = SUBLANG_URDU_PAKISTAN; // Urdu (Pakistan) 472cdf0e10cSrcweir else if ( wsCountry == L"IN" ) 473cdf0e10cSrcweir usSubLang = SUBLANG_URDU_INDIA; // Urdu (India) 474cdf0e10cSrcweir else 475cdf0e10cSrcweir usSubLang = SUBLANG_DEFAULT; //default sub language 476cdf0e10cSrcweir } 477cdf0e10cSrcweir else if ( wsLanguage == L"in" ) 478cdf0e10cSrcweir usPrimaryLang = LANG_INDONESIAN; //Indonesian 479cdf0e10cSrcweir else if ( wsLanguage == L"uk" ) 480cdf0e10cSrcweir usPrimaryLang = LANG_UKRAINIAN; //Ukrainian 481cdf0e10cSrcweir else if ( wsLanguage == L"be" ) 482cdf0e10cSrcweir usPrimaryLang = LANG_BELARUSIAN; //Belarusian 483cdf0e10cSrcweir else if ( wsLanguage == L"sl" ) 484cdf0e10cSrcweir usPrimaryLang = LANG_SLOVENIAN; //Slovenian 485cdf0e10cSrcweir else if ( wsLanguage == L"et" ) 486cdf0e10cSrcweir usPrimaryLang = LANG_ESTONIAN; //Estonian 487cdf0e10cSrcweir else if ( wsLanguage == L"lv" ) 488cdf0e10cSrcweir usPrimaryLang = LANG_LATVIAN; //Latvian 489cdf0e10cSrcweir else if ( wsLanguage == L"lt" ) 490cdf0e10cSrcweir { 491cdf0e10cSrcweir usPrimaryLang = LANG_LITHUANIAN; //Lithuanian 492cdf0e10cSrcweir if ( wsCountry == L"LT" ) 493cdf0e10cSrcweir usSubLang = SUBLANG_LITHUANIAN; // Lithuanian 494cdf0e10cSrcweir else 495cdf0e10cSrcweir usSubLang = SUBLANG_DEFAULT; //default sub language 496cdf0e10cSrcweir } 497cdf0e10cSrcweir else if ( wsLanguage == L"fa" ) 498cdf0e10cSrcweir usPrimaryLang = LANG_FARSI; //Farsi 499cdf0e10cSrcweir else if ( wsLanguage == L"vi" ) 500cdf0e10cSrcweir usPrimaryLang = LANG_VIETNAMESE; //Vietnamese 501cdf0e10cSrcweir else if ( wsLanguage == L"hy" ) 502cdf0e10cSrcweir usPrimaryLang = LANG_ARMENIAN; //Armenian 503cdf0e10cSrcweir else if ( wsLanguage == L"az" ) 504cdf0e10cSrcweir { 505cdf0e10cSrcweir usPrimaryLang = LANG_AZERI; //Azeri 506cdf0e10cSrcweir //if ( wsCountry == L" " ) 507cdf0e10cSrcweir // usSubLang = SUBLANG_AZERI_LATIN; // Azeri (Latin) 508cdf0e10cSrcweir //else if ( wsCountry == L" " ) 509cdf0e10cSrcweir // usSubLang = SUBLANG_AZERI_CYRILLIC; // Azeri (Cyrillic) 510cdf0e10cSrcweir } 511cdf0e10cSrcweir else if ( wsLanguage == L"eu" ) 512cdf0e10cSrcweir usPrimaryLang = LANG_BASQUE; //Basque 513cdf0e10cSrcweir else if ( wsLanguage == L"mk" ) 514cdf0e10cSrcweir usPrimaryLang = LANG_MACEDONIAN; //FYRO Macedonian 515cdf0e10cSrcweir else if ( wsLanguage == L"af" ) 516cdf0e10cSrcweir usPrimaryLang = LANG_AFRIKAANS; //Afrikaans 517cdf0e10cSrcweir else if ( wsLanguage == L"ka" ) 518cdf0e10cSrcweir usPrimaryLang = LANG_GEORGIAN; //Georgian 519cdf0e10cSrcweir else if ( wsLanguage == L"fo" ) 520cdf0e10cSrcweir usPrimaryLang = LANG_FAEROESE; //Faeroese 521cdf0e10cSrcweir else if ( wsLanguage == L"hi" ) 522cdf0e10cSrcweir usPrimaryLang = LANG_HINDI; //Hindi 523cdf0e10cSrcweir else if ( wsLanguage == L"ms" ) 524cdf0e10cSrcweir { 525cdf0e10cSrcweir usPrimaryLang = LANG_MALAY; //Malay 526cdf0e10cSrcweir if ( wsCountry == L"MY" ) 527cdf0e10cSrcweir usSubLang = SUBLANG_MALAY_MALAYSIA; // Malay (Malaysia) 528cdf0e10cSrcweir else if ( wsCountry == L"BN" ) 529cdf0e10cSrcweir usSubLang = SUBLANG_MALAY_BRUNEI_DARUSSALAM; // Malay (Brunei Darassalam) 530cdf0e10cSrcweir else 531cdf0e10cSrcweir usSubLang = SUBLANG_DEFAULT; //default sub language 532cdf0e10cSrcweir } 533cdf0e10cSrcweir else if ( wsLanguage == L"kk" ) 534cdf0e10cSrcweir usPrimaryLang = LANG_KAZAK; //Kazak 535cdf0e10cSrcweir else if ( wsLanguage == L"ky" ) 536cdf0e10cSrcweir usPrimaryLang = LANG_KYRGYZ; //Kyrgyz 537cdf0e10cSrcweir else if ( wsLanguage == L"sw" ) 538cdf0e10cSrcweir usPrimaryLang = LANG_SWAHILI; //Swahili 539cdf0e10cSrcweir else if ( wsLanguage == L"uz" ) 540cdf0e10cSrcweir { 541cdf0e10cSrcweir usPrimaryLang = LANG_UZBEK; //Uzbek 542cdf0e10cSrcweir if ( wsCountry == L"UZ" ) 543cdf0e10cSrcweir usSubLang = SUBLANG_UZBEK_LATIN; // Uzbek (Latin) 544cdf0e10cSrcweir else if ( wsCountry == L"DE" ) 545cdf0e10cSrcweir usSubLang = SUBLANG_UZBEK_CYRILLIC; // Uzbek (Cyrillic) 546cdf0e10cSrcweir else 547cdf0e10cSrcweir usSubLang = SUBLANG_DEFAULT; //default sub language 548cdf0e10cSrcweir } 549cdf0e10cSrcweir else if ( wsLanguage == L"tt" ) 550cdf0e10cSrcweir usPrimaryLang = LANG_TATAR; //Tatar 551cdf0e10cSrcweir else if ( wsLanguage == L"bn" ) 552cdf0e10cSrcweir usPrimaryLang = LANG_BENGALI; //Not supported. 553cdf0e10cSrcweir else if ( wsLanguage == L"pa" ) 554cdf0e10cSrcweir usPrimaryLang = LANG_PUNJABI; //Punjabi 555cdf0e10cSrcweir else if ( wsLanguage == L"gu" ) 556cdf0e10cSrcweir usPrimaryLang = LANG_GUJARATI; //Gujarati 557cdf0e10cSrcweir else if ( wsLanguage == L"or" ) 558cdf0e10cSrcweir usPrimaryLang = LANG_ORIYA; //Not supported. 559cdf0e10cSrcweir else if ( wsLanguage == L"ta" ) 560cdf0e10cSrcweir usPrimaryLang = LANG_TAMIL; //Tamil 561cdf0e10cSrcweir else if ( wsLanguage == L"te" ) 562cdf0e10cSrcweir usPrimaryLang = LANG_TELUGU; //Telugu 563cdf0e10cSrcweir else if ( wsLanguage == L"kn" ) 564cdf0e10cSrcweir usPrimaryLang = LANG_KANNADA; //Kannada 565cdf0e10cSrcweir else if ( wsLanguage == L"ml" ) 566cdf0e10cSrcweir usPrimaryLang = LANG_MALAYALAM; //Not supported. 567cdf0e10cSrcweir else if ( wsLanguage == L"as" ) 568cdf0e10cSrcweir usPrimaryLang = LANG_ASSAMESE; //Not supported. 569cdf0e10cSrcweir else if ( wsLanguage == L"mr" ) 570cdf0e10cSrcweir usPrimaryLang = LANG_MARATHI; //Marathi 571cdf0e10cSrcweir else if ( wsLanguage == L"sa" ) 572cdf0e10cSrcweir usPrimaryLang = LANG_SANSKRIT; //Sanskrit 573cdf0e10cSrcweir else if ( wsLanguage == L"mn" ) 574cdf0e10cSrcweir usPrimaryLang = LANG_MONGOLIAN; //Mongolian 575cdf0e10cSrcweir else if ( wsLanguage == L"gl" ) 576cdf0e10cSrcweir usPrimaryLang = LANG_GALICIAN; //Galician 577cdf0e10cSrcweir else if ( wsLanguage == L"sd" ) 578cdf0e10cSrcweir usPrimaryLang = LANG_SINDHI; //Not supported. 579cdf0e10cSrcweir else if ( wsLanguage == L"ks" ) 580cdf0e10cSrcweir usPrimaryLang = LANG_KASHMIRI; //Not supported. 581cdf0e10cSrcweir else if ( wsLanguage == L"ne" ) 582cdf0e10cSrcweir usPrimaryLang = LANG_NEPALI; //Not supported. 583cdf0e10cSrcweir //else if ( wsLanguage == L" " ) 584cdf0e10cSrcweir // usPrimaryLang = LANG_MANIPURI; //Not supported. 585cdf0e10cSrcweir //else if ( wsLanguage == L" " ) 586cdf0e10cSrcweir // usPrimaryLang = LANG_KONKANI; //Konkani 587cdf0e10cSrcweir //else if ( wsLanguage == L" " ) 588cdf0e10cSrcweir // usPrimaryLang = LANG_SYRIAC; //Syriac 589cdf0e10cSrcweir //else if ( wsLanguage == L" " ) 590cdf0e10cSrcweir // usPrimaryLang = LANG_DIVEHI; //Divehi 591cdf0e10cSrcweir else 592cdf0e10cSrcweir return GetSystemDefaultLCID(); //System Default Locale 593cdf0e10cSrcweir 594cdf0e10cSrcweir return MAKELCID( MAKELANGID( usPrimaryLang, usSubLang ), SORT_DEFAULT ); 595cdf0e10cSrcweir } 596