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.

245 lines
6.2 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. CCAPolicyAboutImpl::CCAPolicyAboutImpl()
  10. {
  11. }
  12. CCAPolicyAboutImpl::~CCAPolicyAboutImpl()
  13. {
  14. }
  15. HRESULT CCAPolicyAboutImpl::AboutHelper(UINT nID, LPOLESTR* lpPtr)
  16. {
  17. if (lpPtr == NULL)
  18. return E_POINTER;
  19. CString s;
  20. // Needed for Loadstring
  21. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  22. s.LoadString(nID);
  23. *lpPtr = reinterpret_cast<LPOLESTR>
  24. (CoTaskMemAlloc((s.GetLength() + 1)* sizeof(wchar_t)));
  25. if (*lpPtr == NULL)
  26. return E_OUTOFMEMORY;
  27. USES_CONVERSION;
  28. wcscpy(*lpPtr, T2OLE((LPTSTR)(LPCTSTR)s));
  29. return S_OK;
  30. }
  31. HRESULT CCAPolicyAboutImpl::AboutHelper2(LPSTR str, LPOLESTR* lpPtr)
  32. {
  33. LPWSTR pwszTmp = NULL;
  34. if (!myConvertSzToWsz(&pwszTmp, str, -1))
  35. return myHLastError();
  36. *lpPtr = reinterpret_cast<LPOLESTR>
  37. (CoTaskMemAlloc((wcslen(pwszTmp)+1)*sizeof(wchar_t)));
  38. if(*lpPtr == NULL)
  39. return E_OUTOFMEMORY;
  40. wcscpy(*lpPtr, pwszTmp);
  41. LOCAL_FREE(pwszTmp);
  42. return S_OK;
  43. }
  44. STDMETHODIMP CCAPolicyAboutImpl::GetSnapinDescription(LPOLESTR* lpDescription)
  45. {
  46. return AboutHelper(IDS_CAPOLICY_DESCRIPTION, lpDescription);
  47. }
  48. STDMETHODIMP CCAPolicyAboutImpl::GetProvider(LPOLESTR* lpName)
  49. {
  50. return AboutHelper(IDS_COMPANY, lpName);
  51. }
  52. STDMETHODIMP CCAPolicyAboutImpl::GetSnapinVersion(LPOLESTR* lpVersion)
  53. {
  54. return AboutHelper2(VER_PRODUCTVERSION_STR, lpVersion);
  55. }
  56. STDMETHODIMP CCAPolicyAboutImpl::GetSnapinImage(HICON* hAppIcon)
  57. {
  58. if (hAppIcon == NULL)
  59. return E_POINTER;
  60. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  61. // in MMC 1.1, this will be used as root node icon!!
  62. *hAppIcon = LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_APPICON));
  63. ASSERT(*hAppIcon != NULL);
  64. return (*hAppIcon != NULL) ? S_OK : E_FAIL;
  65. }
  66. STDMETHODIMP CCAPolicyAboutImpl::GetStaticFolderImage(HBITMAP* hSmallImage,
  67. HBITMAP* hSmallImageOpen,
  68. HBITMAP* hLargeImage,
  69. COLORREF* cLargeMask)
  70. {
  71. ASSERT(hSmallImage != NULL);
  72. ASSERT(hSmallImageOpen != NULL);
  73. ASSERT(hLargeImage != NULL);
  74. ASSERT(cLargeMask != NULL);
  75. AFX_MANAGE_STATE(AfxGetStaticModuleState()); // Required for AfxGetInstanceHandle()
  76. HINSTANCE hInstance = AfxGetInstanceHandle();
  77. *hSmallImage = ::LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_FOLDER_SMALL));
  78. *hSmallImageOpen = ::LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_FOLDER_SMALL));
  79. *hLargeImage = ::LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_FOLDER_LARGE));
  80. *cLargeMask = RGB(255, 0, 255);
  81. #ifdef _DEBUG
  82. if (NULL == *hSmallImage || NULL == *hSmallImageOpen || NULL == *hLargeImage)
  83. {
  84. OutputDebugString(L"WRN: CSnapinAbout::GetStaticFolderImage() - Unable to load all the bitmaps.\n");
  85. return E_FAIL;
  86. }
  87. #endif
  88. return S_OK;
  89. }
  90. CCertTypeAboutImpl::CCertTypeAboutImpl()
  91. {
  92. }
  93. CCertTypeAboutImpl::~CCertTypeAboutImpl()
  94. {
  95. }
  96. HRESULT CCertTypeAboutImpl::AboutHelper(UINT nID, LPOLESTR* lpPtr)
  97. {
  98. if (lpPtr == NULL)
  99. return E_POINTER;
  100. CString s;
  101. // Needed for Loadstring
  102. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  103. s.LoadString(nID);
  104. *lpPtr = reinterpret_cast<LPOLESTR>
  105. (CoTaskMemAlloc((s.GetLength() + 1)* sizeof(wchar_t)));
  106. if (*lpPtr == NULL)
  107. return E_OUTOFMEMORY;
  108. USES_CONVERSION;
  109. wcscpy(*lpPtr, T2OLE((LPTSTR)(LPCTSTR)s));
  110. return S_OK;
  111. }
  112. HRESULT CCertTypeAboutImpl::AboutHelper2(LPSTR str, LPOLESTR* lpPtr)
  113. {
  114. LPWSTR pwszTmp = NULL;
  115. if (!myConvertSzToWsz(&pwszTmp, str, -1))
  116. return myHLastError();
  117. *lpPtr = reinterpret_cast<LPOLESTR>
  118. (CoTaskMemAlloc((wcslen(pwszTmp)+1)*sizeof(wchar_t)));
  119. if(*lpPtr == NULL)
  120. return E_OUTOFMEMORY;
  121. wcscpy(*lpPtr, pwszTmp);
  122. LOCAL_FREE(pwszTmp);
  123. return S_OK;
  124. }
  125. STDMETHODIMP CCertTypeAboutImpl::GetSnapinDescription(LPOLESTR* lpDescription)
  126. {
  127. return AboutHelper(IDS_CERTTYPE_DESCRIPTION, lpDescription);
  128. }
  129. STDMETHODIMP CCertTypeAboutImpl::GetProvider(LPOLESTR* lpName)
  130. {
  131. return AboutHelper(IDS_COMPANY, lpName);
  132. }
  133. STDMETHODIMP CCertTypeAboutImpl::GetSnapinVersion(LPOLESTR* lpVersion)
  134. {
  135. return AboutHelper2(VER_PRODUCTVERSION_STR, lpVersion);
  136. }
  137. STDMETHODIMP CCertTypeAboutImpl::GetSnapinImage(HICON* hAppIcon)
  138. {
  139. if (hAppIcon == NULL)
  140. return E_POINTER;
  141. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  142. // in MMC 1.1, this will be used as root node icon!!
  143. *hAppIcon = LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_APPICON));
  144. ASSERT(*hAppIcon != NULL);
  145. return (*hAppIcon != NULL) ? S_OK : E_FAIL;
  146. }
  147. STDMETHODIMP CCertTypeAboutImpl::GetStaticFolderImage(HBITMAP* hSmallImage,
  148. HBITMAP* hSmallImageOpen,
  149. HBITMAP* hLargeImage,
  150. COLORREF* cLargeMask)
  151. {
  152. ASSERT(hSmallImage != NULL);
  153. ASSERT(hSmallImageOpen != NULL);
  154. ASSERT(hLargeImage != NULL);
  155. ASSERT(cLargeMask != NULL);
  156. AFX_MANAGE_STATE(AfxGetStaticModuleState()); // Required for AfxGetInstanceHandle()
  157. HINSTANCE hInstance = AfxGetInstanceHandle();
  158. *hSmallImage = ::LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_FOLDER_SMALL));
  159. *hSmallImageOpen = ::LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_FOLDER_SMALL));
  160. *hLargeImage = ::LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_FOLDER_LARGE));
  161. *cLargeMask = RGB(255, 0, 255);
  162. #ifdef _DEBUG
  163. if (NULL == *hSmallImage || NULL == *hSmallImageOpen || NULL == *hLargeImage)
  164. {
  165. OutputDebugString(L"WRN: CSnapinAbout::GetStaticFolderImage() - Unable to load all the bitmaps.\n");
  166. return E_FAIL;
  167. }
  168. #endif
  169. return S_OK;
  170. }