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.

113 lines
3.3 KiB

  1. #include "stdafx.h"
  2. #include "pop3snap.h"
  3. ////////////////////////////////////////////////////////////////////////////////////////////////////
  4. //////////////////////////////////////////////////////////////////////////////////////////////////
  5. //
  6. // CPOP3ServerSnapData
  7. //
  8. //////////////////////////////////////////////////////////////////////////////////////////////////
  9. ////////////////////////////////////////////////////////////////////////////////////////////////////
  10. HRESULT CPOP3ServerSnapData::Initialize(LPUNKNOWN pUnknown)
  11. {
  12. if( !pUnknown ) return E_INVALIDARG;
  13. HRESULT hr = IComponentDataImpl<CPOP3ServerSnapData, CPOP3ServerSnapComponent >::Initialize(pUnknown);
  14. if( FAILED(hr) ) return hr;
  15. CComPtr<IImageList> spImageList;
  16. if( m_spConsole->QueryScopeImageList(&spImageList) != S_OK )
  17. {
  18. ATLTRACE(_T("IConsole::QueryScopeImageList failed\n"));
  19. return E_UNEXPECTED;
  20. }
  21. hr = LoadImages(spImageList);
  22. return hr;
  23. }
  24. HRESULT WINAPI CPOP3ServerSnapData::UpdateRegistry(BOOL bRegister)
  25. {
  26. // Load snap-in name
  27. tstring strSnapinName = StrLoadString(IDS_SNAPINNAME);
  28. // Specify the substitution parameters for IRegistrar.
  29. _ATL_REGMAP_ENTRY rgEntries[] =
  30. {
  31. {TEXT("SNAPIN_NAME"), strSnapinName.c_str()},
  32. {NULL, NULL},
  33. };
  34. // Register the component data object
  35. HRESULT hr = _Module.UpdateRegistryFromResource(IDR_POP3SERVERSNAP, bRegister, rgEntries);
  36. return hr;
  37. }
  38. HRESULT CPOP3ServerSnapData::GetHelpTopic(LPOLESTR* ppszHelpFile)
  39. {
  40. if( !ppszHelpFile ) return E_INVALIDARG;
  41. *ppszHelpFile = NULL;
  42. TCHAR szWindowsDir[MAX_PATH+1] = {0};
  43. tstring strHelpFile = _T("");
  44. tstring strHelpFileName = StrLoadString(IDS_HELPFILE);
  45. if( strHelpFileName.empty() ) return E_FAIL;
  46. // Build path to %systemroot%\help
  47. UINT nSize = GetSystemWindowsDirectory( szWindowsDir, MAX_PATH );
  48. if( nSize == 0 || nSize > MAX_PATH )
  49. {
  50. return E_FAIL;
  51. }
  52. strHelpFile = szWindowsDir; // D:\windows
  53. strHelpFile += _T("\\Help\\"); // \help
  54. strHelpFile += strHelpFileName; // \filename.chm
  55. // Form file path in allocated buffer
  56. int nLen = strHelpFile.length() + 1;
  57. *ppszHelpFile = (LPOLESTR)CoTaskMemAlloc(nLen * sizeof(WCHAR));
  58. if( *ppszHelpFile == NULL ) return E_OUTOFMEMORY;
  59. // Copy into allocated buffer
  60. ocscpy( *ppszHelpFile, T2OLE((LPTSTR)strHelpFile.c_str()) );
  61. return S_OK;
  62. }
  63. HRESULT CPOP3ServerSnapData::GetLinkedTopics(LPOLESTR* ppszLinkedFiles)
  64. {
  65. if( !ppszLinkedFiles ) return E_INVALIDARG;
  66. // no linked files
  67. *ppszLinkedFiles = NULL;
  68. return S_FALSE;
  69. }
  70. // called by menu handlers
  71. HRESULT GetConsole( CSnapInObjectRootBase *pObj, IConsole** pConsole )
  72. {
  73. if( !pObj || !pConsole ) return E_INVALIDARG;
  74. if( (pObj->m_nType != 1) && (pObj->m_nType != 2) ) return E_INVALIDARG;
  75. if (pObj->m_nType == 1)
  76. {
  77. *pConsole = ((CPOP3ServerSnapData*) pObj)->m_spConsole;
  78. }
  79. else
  80. {
  81. *pConsole = ((CPOP3ServerSnapComponent*) pObj)->m_spConsole;
  82. }
  83. if( !*pConsole ) return E_NOINTERFACE;
  84. (*pConsole)->AddRef();
  85. return S_OK;
  86. }