Leaked source code of windows server 2003
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.

146 lines
3.4 KiB

  1. /******************************************************************************
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. HelpSet.cpp
  5. Abstract:
  6. This file contains the implementation of the Taxonomy::HelpSet class,
  7. that is used as an identifier for the set of Help files to operate upon.
  8. Revision History:
  9. Davide Massarenti (Dmassare) 11/25/2000
  10. created
  11. ******************************************************************************/
  12. #include "stdafx.h"
  13. ////////////////////////////////////////////////////////////////////////////////
  14. MPC::wstring Taxonomy::HelpSet::m_strSKU_Machine;
  15. long Taxonomy::HelpSet::m_lLCID_Machine;
  16. ////////////////////
  17. HRESULT Taxonomy::HelpSet::SetMachineInfo( /*[in]*/ const InstanceBase& inst )
  18. {
  19. m_strSKU_Machine = inst.m_ths.m_strSKU;
  20. m_lLCID_Machine = inst.m_ths.m_lLCID;
  21. return S_OK;
  22. }
  23. DWORD Taxonomy::HelpSet::GetMachineLCID()
  24. {
  25. return ::GetSystemDefaultLCID();
  26. }
  27. DWORD Taxonomy::HelpSet::GetUserLCID()
  28. {
  29. return MAKELCID( ::GetUserDefaultUILanguage(), SORTIDFROMLCID( GetMachineLCID() ) );
  30. }
  31. void Taxonomy::HelpSet::GetLCIDDisplayString( /*[in]*/ long lLCID, /*[out]*/ MPC::wstring& str )
  32. {
  33. WCHAR rgTmp[256];
  34. if(::GetLocaleInfoW( lLCID, LOCALE_SLANGUAGE, rgTmp, MAXSTRLEN(rgTmp) ))
  35. {
  36. str = rgTmp;
  37. }
  38. }
  39. ////////////////////
  40. Taxonomy::HelpSet::HelpSet( /*[in]*/ LPCWSTR szSKU ,
  41. /*[in]*/ long lLCID )
  42. {
  43. (void)Initialize( szSKU, lLCID );
  44. }
  45. Taxonomy::HelpSet::HelpSet( /*[in]*/ const HelpSet& ths )
  46. {
  47. *this = ths;
  48. }
  49. Taxonomy::HelpSet& Taxonomy::HelpSet::operator=( /*[in]*/ const HelpSet& ths )
  50. {
  51. m_strSKU = ths.m_strSKU;
  52. m_lLCID = ths.m_lLCID ;
  53. return *this;
  54. }
  55. ////////////////////
  56. HRESULT Taxonomy::HelpSet::Initialize( /*[in]*/ LPCWSTR szSKU ,
  57. /*[in]*/ long lLCID )
  58. {
  59. m_strSKU = STRINGISPRESENT(szSKU) ? szSKU : m_strSKU_Machine.c_str();
  60. m_lLCID = lLCID ? lLCID : m_lLCID_Machine;
  61. return S_OK;
  62. }
  63. HRESULT Taxonomy::HelpSet::Initialize( /*[in]*/ LPCWSTR szSKU ,
  64. /*[in]*/ LPCWSTR szLanguage )
  65. {
  66. return Initialize( szSKU, STRINGISPRESENT(szLanguage) ? _wtol( szLanguage ) : 0 );
  67. }
  68. ////////////////////
  69. bool Taxonomy::HelpSet::IsMachineHelp() const
  70. {
  71. return !_wcsicmp( GetSKU () , GetMachineSKU () ) &&
  72. GetLanguage() == GetMachineLanguage() ;
  73. }
  74. ////////////////////
  75. bool Taxonomy::HelpSet::operator==( /*[in]*/ const HelpSet& sel ) const
  76. {
  77. return !_wcsicmp( GetSKU () , sel.GetSKU () ) &&
  78. GetLanguage() == sel.GetLanguage() ;
  79. }
  80. bool Taxonomy::HelpSet::operator<( /*[in]*/ const HelpSet& sel ) const
  81. {
  82. int iCmp = _wcsicmp( GetSKU(), sel.GetSKU() );
  83. if(iCmp == 0)
  84. {
  85. iCmp = (int)(GetLanguage() - sel.GetLanguage());
  86. }
  87. return (iCmp < 0);
  88. }
  89. HRESULT Taxonomy::operator>>( /*[in]*/ MPC::Serializer& stream, /*[out]*/ Taxonomy::HelpSet& val )
  90. {
  91. HRESULT hr;
  92. if(SUCCEEDED(hr = (stream >> val.m_strSKU)) &&
  93. SUCCEEDED(hr = (stream >> val.m_lLCID )) )
  94. {
  95. hr = S_OK;
  96. }
  97. return hr;
  98. }
  99. HRESULT Taxonomy::operator<<( /*[in]*/ MPC::Serializer& stream, /*[in] */ const Taxonomy::HelpSet& val )
  100. {
  101. HRESULT hr;
  102. if(SUCCEEDED(hr = (stream << val.m_strSKU)) &&
  103. SUCCEEDED(hr = (stream << val.m_lLCID )) )
  104. {
  105. hr = S_OK;
  106. }
  107. return hr;
  108. }