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.

113 lines
2.8 KiB

  1. // This is a part of the Microsoft Management Console.
  2. // Copyright (C) Microsoft Corporation, 1995 - 1999
  3. // All rights reserved.
  4. //
  5. // This source code is only intended as a supplement to the
  6. // Microsoft Management Console and related
  7. // electronic documentation provided with the interfaces.
  8. #include <stdafx.h>
  9. #ifdef _DEBUG
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13. CSnapinAboutImpl::CSnapinAboutImpl()
  14. {
  15. }
  16. CSnapinAboutImpl::~CSnapinAboutImpl()
  17. {
  18. }
  19. HRESULT CSnapinAboutImpl::AboutHelper(UINT nID, LPOLESTR* lpPtr)
  20. {
  21. if (lpPtr == NULL)
  22. return E_POINTER;
  23. CString s;
  24. // Needed for Loadstring
  25. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  26. s.LoadString(nID);
  27. *lpPtr = reinterpret_cast<LPOLESTR>
  28. ( CoTaskMemAlloc( (s.GetLength()+1)*sizeof(WCHAR) ));
  29. if (*lpPtr == NULL)
  30. return E_OUTOFMEMORY;
  31. myRegisterMemFree(*lpPtr, CSM_COTASKALLOC); // this is freed by mmc, not our tracking
  32. USES_CONVERSION;
  33. wcscpy(*lpPtr, T2OLE((LPTSTR)(LPCTSTR)s));
  34. return S_OK;
  35. }
  36. STDMETHODIMP CSnapinAboutImpl::GetSnapinDescription(LPOLESTR* lpDescription)
  37. {
  38. return AboutHelper(IDS_DESCRIPTION, lpDescription);
  39. }
  40. STDMETHODIMP CSnapinAboutImpl::GetProvider(LPOLESTR* lpName)
  41. {
  42. return AboutHelper(IDS_COMPANY, lpName);
  43. }
  44. STDMETHODIMP CSnapinAboutImpl::GetSnapinVersion(LPOLESTR* lpVersion)
  45. {
  46. return AboutHelper(IDS_VERSION, lpVersion);
  47. }
  48. STDMETHODIMP CSnapinAboutImpl::GetSnapinImage(HICON* hAppIcon)
  49. {
  50. if (hAppIcon == NULL)
  51. return E_POINTER;
  52. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  53. // in MMC 1.1, this will be used as root node icon!!
  54. *hAppIcon = LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_APPICON));
  55. ASSERT(*hAppIcon != NULL);
  56. return (*hAppIcon != NULL) ? S_OK : E_FAIL;
  57. }
  58. STDMETHODIMP CSnapinAboutImpl::GetStaticFolderImage(HBITMAP* hSmallImage,
  59. HBITMAP* hSmallImageOpen,
  60. HBITMAP* hLargeImage,
  61. COLORREF* cLargeMask)
  62. {
  63. ASSERT(hSmallImage != NULL);
  64. ASSERT(hSmallImageOpen != NULL);
  65. ASSERT(hLargeImage != NULL);
  66. ASSERT(cLargeMask != NULL);
  67. AFX_MANAGE_STATE(AfxGetStaticModuleState()); // Required for AfxGetInstanceHandle()
  68. HINSTANCE hInstance = AfxGetInstanceHandle();
  69. *hSmallImage = ::LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_COMPUTER_SMALL));
  70. *hSmallImageOpen = ::LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_COMPUTER_SMALL));
  71. *hLargeImage = ::LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_COMPUTER_LARGE));
  72. *cLargeMask = RGB(255, 0, 255);
  73. #ifdef _DEBUG
  74. if (NULL == *hSmallImage || NULL == *hSmallImageOpen || NULL == *hLargeImage)
  75. {
  76. OutputDebugString(L"WRN: CSnapinAbout::GetStaticFolderImage() - Unable to load all the bitmaps.\n");
  77. return E_FAIL;
  78. }
  79. #endif
  80. return S_OK;
  81. }