Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

169 lines
4.3 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Copyright (C) Microsoft Corporation, 1996 - 1998.
  4. //
  5. // File: WEBLANG.CXX
  6. //
  7. // Contents: Language Support
  8. //
  9. // Classes: CWebLangLocator
  10. //
  11. // History: 96-Feb-29 DwightKr Created
  12. //
  13. //----------------------------------------------------------------------------
  14. #include <pch.cxx>
  15. #pragma hdrstop
  16. //+-------------------------------------------------------------------------
  17. //
  18. // Method: CWebLangLocator::CWebLangLocator
  19. //
  20. // Arguments: [locale] -- current locale
  21. //
  22. // History: 96-Feb-29 DwightKr Created.
  23. //
  24. //--------------------------------------------------------------------------
  25. CWebLangLocator::CWebLangLocator( LCID locale )
  26. : _locale( LANGIDFROMLCID(locale) ),
  27. _localeSys( GetSystemDefaultLangID() ),
  28. _fLocaleFound( FALSE ),
  29. _fLangFound( FALSE ),
  30. _fSysLangFound( FALSE )
  31. {
  32. _wcsIDQErrorFile[0] = 0;
  33. _wcsHTXErrorFile[0] = 0;
  34. _wcsRestrictionErrorFile[0] = 0;
  35. _wcsDefaultErrorFile[0] = 0;
  36. EnumLangEntries();
  37. }
  38. //+-------------------------------------------------------------------------
  39. //
  40. // Method: CWebLangLocator::EnumLangEntries, private
  41. //
  42. // Synposis: Enumerates lang subkeys
  43. //
  44. // Arguments: none
  45. //
  46. // returns: none
  47. //
  48. // History: 4/23/98 mohamedn created
  49. //
  50. //--------------------------------------------------------------------------
  51. void CWebLangLocator::EnumLangEntries(void)
  52. {
  53. CWin32RegAccess langKey( HKEY_LOCAL_MACHINE, wcsRegAdminLanguage );
  54. WCHAR wcsSubKeyName[MAX_PATH+1];
  55. DWORD cwcName = sizeof wcsSubKeyName / sizeof WCHAR;
  56. while ( langKey.Enum( wcsSubKeyName, cwcName ) )
  57. {
  58. CWin32RegAccess langSubKey( langKey.GetHKey() , wcsSubKeyName );
  59. DWORD dwLocaleId = 0;
  60. if ( langSubKey.Get( L"Locale", dwLocaleId ) )
  61. {
  62. GetLangInfo( dwLocaleId, langSubKey );
  63. }
  64. }
  65. }
  66. //+-------------------------------------------------------------------------
  67. //
  68. // Method: CWebLangLocator::GetLangInfo, private
  69. //
  70. // Synposis: Get error files if _locale matches.
  71. //
  72. // Arguments: [dwLocaleValue] -- value of locale found
  73. // [regLang] -- registry lang. subkey accessor.
  74. //
  75. // returns: none
  76. //
  77. // History: 4/23/98 mohamedn created
  78. //
  79. //--------------------------------------------------------------------------
  80. void CWebLangLocator::GetLangInfo(DWORD dwLocaleValue, CWin32RegAccess & regLang)
  81. {
  82. if ( _fLocaleFound )
  83. return;
  84. //
  85. // Temporary state
  86. //
  87. BOOL fLocaleFound = _fLocaleFound;
  88. BOOL fLangFound = _fLangFound;
  89. BOOL fSysLangFound = _fSysLangFound;
  90. DWORD dwLocale = LANGIDFROMLCID( dwLocaleValue );
  91. BOOL fFetch = FALSE;
  92. if ( dwLocale == _locale )
  93. {
  94. fFetch = TRUE;
  95. fLocaleFound = TRUE;
  96. }
  97. else if ( !fLangFound && PrimaryLangsMatch( dwLocale, _locale ) )
  98. {
  99. fFetch = TRUE;
  100. fLangFound = TRUE;
  101. }
  102. else if ( !fLangFound && !fSysLangFound && (dwLocale == _localeSys) )
  103. {
  104. fFetch = TRUE;
  105. fSysLangFound = TRUE;
  106. }
  107. if ( fFetch )
  108. {
  109. BOOL fRetVal = FALSE;
  110. fRetVal = regLang.Get( L"ISAPIIDQErrorFile", _wcsIDQErrorFile,
  111. sizeof(_wcsIDQErrorFile) / sizeof (WCHAR) );
  112. if ( fRetVal )
  113. {
  114. fRetVal = regLang.Get( L"ISAPIHTXErrorFile", _wcsHTXErrorFile,
  115. sizeof(_wcsHTXErrorFile) / sizeof(WCHAR) );
  116. }
  117. if ( fRetVal )
  118. {
  119. fRetVal = regLang.Get( L"ISAPIRestrictionErrorFile", _wcsRestrictionErrorFile,
  120. sizeof(_wcsRestrictionErrorFile) / sizeof(WCHAR) );
  121. }
  122. if ( fRetVal )
  123. {
  124. fRetVal = regLang.Get( L"ISAPIDefaultErrorFile", _wcsDefaultErrorFile,
  125. sizeof(_wcsDefaultErrorFile) / sizeof(WCHAR) );
  126. }
  127. //
  128. // if we fail to retrieve error files, don't update internal state.
  129. //
  130. if ( !fRetVal )
  131. {
  132. ciGibDebugOut(( DEB_ERROR, "CWebLangLocator::GetLangInfo() Failed\n" ));
  133. return;
  134. }
  135. }
  136. //
  137. // Make sure this is done *after* the fetch, which can fail.
  138. //
  139. _fLocaleFound = fLocaleFound;
  140. _fLangFound = fLangFound;
  141. _fSysLangFound = fSysLangFound;
  142. }