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