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.

147 lines
3.7 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. #define __dwFILE__ __dwFILE_CERTMMC_ABOUT_CPP__
  10. #ifdef _DEBUG
  11. #undef THIS_FILE
  12. static char THIS_FILE[] = __FILE__;
  13. #endif
  14. CSnapinAboutImpl::CSnapinAboutImpl()
  15. {
  16. }
  17. CSnapinAboutImpl::~CSnapinAboutImpl()
  18. {
  19. }
  20. HRESULT CSnapinAboutImpl::AboutHelper(UINT nID, LPOLESTR* lpPtr)
  21. {
  22. if (lpPtr == NULL)
  23. return E_POINTER;
  24. CString s;
  25. // Needed for Loadstring
  26. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  27. s.LoadString(nID);
  28. *lpPtr = reinterpret_cast<LPOLESTR>
  29. ( CoTaskMemAlloc( (s.GetLength()+1)*sizeof(WCHAR) ));
  30. if (*lpPtr == NULL)
  31. return E_OUTOFMEMORY;
  32. // this is freed by mmc, not our tracking
  33. myRegisterMemFree(*lpPtr, CSM_COTASKALLOC);
  34. USES_CONVERSION;
  35. wcscpy(*lpPtr, T2OLE((LPTSTR)(LPCTSTR)s));
  36. return S_OK;
  37. }
  38. HRESULT CSnapinAboutImpl::AboutHelper2(LPSTR str, LPOLESTR* lpPtr)
  39. {
  40. HRESULT hr;
  41. LPWSTR pwszTmp = NULL;
  42. if (!myConvertSzToWsz(&pwszTmp, str, -1))
  43. {
  44. hr = E_OUTOFMEMORY;
  45. _JumpError(hr, error, "myConvertSzToWsz");
  46. }
  47. *lpPtr = reinterpret_cast<LPOLESTR>
  48. (CoTaskMemAlloc((wcslen(pwszTmp)+1)*sizeof(wchar_t)));
  49. if (NULL == *lpPtr)
  50. {
  51. hr = E_OUTOFMEMORY;
  52. _JumpError(hr, error, "CoTaskMemAlloc");
  53. }
  54. // this is freed by mmc, not our tracking
  55. myRegisterMemFree(*lpPtr, CSM_COTASKALLOC);
  56. wcscpy(*lpPtr, pwszTmp);
  57. hr = S_OK;
  58. error:
  59. if (NULL != pwszTmp)
  60. {
  61. LocalFree(pwszTmp);
  62. }
  63. return(hr);
  64. }
  65. STDMETHODIMP CSnapinAboutImpl::GetSnapinDescription(LPOLESTR* lpDescription)
  66. {
  67. return AboutHelper(IDS_DESCRIPTION, lpDescription);
  68. }
  69. STDMETHODIMP CSnapinAboutImpl::GetProvider(LPOLESTR* lpName)
  70. {
  71. return AboutHelper(IDS_COMPANY, lpName);
  72. }
  73. STDMETHODIMP CSnapinAboutImpl::GetSnapinVersion(LPOLESTR* lpVersion)
  74. {
  75. return AboutHelper2(VER_PRODUCTVERSION_STR, lpVersion);
  76. }
  77. STDMETHODIMP CSnapinAboutImpl::GetSnapinImage(HICON* hAppIcon)
  78. {
  79. if (hAppIcon == NULL)
  80. return E_POINTER;
  81. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  82. // in MMC 1.1, this will be used as root node icon!!
  83. *hAppIcon = LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_APPICON));
  84. ASSERT(*hAppIcon != NULL);
  85. return (*hAppIcon != NULL) ? S_OK : E_FAIL;
  86. }
  87. STDMETHODIMP CSnapinAboutImpl::GetStaticFolderImage(HBITMAP* hSmallImage,
  88. HBITMAP* hSmallImageOpen,
  89. HBITMAP* hLargeImage,
  90. COLORREF* cLargeMask)
  91. {
  92. ASSERT(hSmallImage != NULL);
  93. ASSERT(hSmallImageOpen != NULL);
  94. ASSERT(hLargeImage != NULL);
  95. ASSERT(cLargeMask != NULL);
  96. AFX_MANAGE_STATE(AfxGetStaticModuleState()); // Required for AfxGetInstanceHandle()
  97. HINSTANCE hInstance = AfxGetInstanceHandle();
  98. *hSmallImage = ::LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_COMPUTER_SMALL));
  99. *hSmallImageOpen = ::LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_COMPUTER_SMALL));
  100. *hLargeImage = ::LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_COMPUTER_LARGE));
  101. *cLargeMask = RGB(255, 0, 255);
  102. #ifdef _DEBUG
  103. if (NULL == *hSmallImage || NULL == *hSmallImageOpen || NULL == *hLargeImage)
  104. {
  105. OutputDebugString(L"WRN: CSnapinAbout::GetStaticFolderImage() - Unable to load all the bitmaps.\n");
  106. return E_FAIL;
  107. }
  108. #endif
  109. return S_OK;
  110. }