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.

206 lines
6.8 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation 1996-2001.
  5. //
  6. // File: about.cpp
  7. //
  8. // Contents: implementation of CAbout, CSCEAbout, CSCMAbout, CSSAbout,
  9. // CRSOPAbout & CLSAbout
  10. //
  11. //----------------------------------------------------------------------------
  12. #include "stdafx.h"
  13. #include "resource.h"
  14. #include "about.h"
  15. #include <ntverp.h>
  16. #define OUT_VERSION VER_PRODUCTVERSION_STR
  17. #define OUT_PROVIDER VER_COMPANYNAME_STR
  18. /////////////////////////////////////////////////////////////////////
  19. CSCEAbout::CSCEAbout()
  20. {
  21. m_uIdStrProvider = IDS_SNAPINABOUT_PROVIDER;
  22. m_uIdStrVersion = IDS_SNAPINABOUT_VERSION;
  23. m_uIdStrDescription = IDS_SCEABOUT_DESCRIPTION;
  24. m_uIdIconImage = IDI_SCE_APP;
  25. m_uIdBitmapSmallImage = IDB_SCE_SMALL;
  26. m_uIdBitmapSmallImageOpen = IDB_SCE_SMALL;
  27. m_uIdBitmapLargeImage = IDB_SCE_LARGE;
  28. m_crImageMask = RGB(255, 0, 255);
  29. }
  30. CSCMAbout::CSCMAbout()
  31. {
  32. m_uIdStrProvider = IDS_SNAPINABOUT_PROVIDER;
  33. m_uIdStrVersion = IDS_SNAPINABOUT_VERSION;
  34. m_uIdStrDescription = IDS_SCMABOUT_DESCRIPTION;
  35. m_uIdIconImage = IDI_SCE_APP;
  36. m_uIdBitmapSmallImage = IDB_SCE_SMALL;
  37. m_uIdBitmapSmallImageOpen = IDB_SCE_SMALL;
  38. m_uIdBitmapLargeImage = IDB_SCE_LARGE;
  39. m_crImageMask = RGB(255, 0, 255);
  40. }
  41. CSSAbout::CSSAbout()
  42. {
  43. m_uIdStrProvider = IDS_SNAPINABOUT_PROVIDER;
  44. m_uIdStrVersion = IDS_SNAPINABOUT_VERSION;
  45. m_uIdStrDescription = IDS_SSABOUT_DESCRIPTION;
  46. m_uIdIconImage = IDI_SCE_APP;
  47. m_uIdBitmapSmallImage = IDB_SCE_SMALL;
  48. m_uIdBitmapSmallImageOpen = IDB_SCE_SMALL;
  49. m_uIdBitmapLargeImage = IDB_SCE_LARGE;
  50. m_crImageMask = RGB(255, 0, 255);
  51. }
  52. CRSOPAbout::CRSOPAbout()
  53. {
  54. m_uIdStrProvider = IDS_SNAPINABOUT_PROVIDER;
  55. m_uIdStrVersion = IDS_SNAPINABOUT_VERSION;
  56. m_uIdStrDescription = IDS_RSOPABOUT_DESCRIPTION;
  57. m_uIdIconImage = IDI_SCE_APP;
  58. m_uIdBitmapSmallImage = IDB_SCE_SMALL;
  59. m_uIdBitmapSmallImageOpen = IDB_SCE_SMALL;
  60. m_uIdBitmapLargeImage = IDB_SCE_LARGE;
  61. m_crImageMask = RGB(255, 0, 255);
  62. }
  63. CLSAbout::CLSAbout()
  64. {
  65. m_uIdStrProvider = IDS_SNAPINABOUT_PROVIDER;
  66. m_uIdStrVersion = IDS_SNAPINABOUT_VERSION;
  67. m_uIdStrDescription = IDS_LSABOUT_DESCRIPTION;
  68. m_uIdIconImage = IDI_SCE_APP;
  69. m_uIdBitmapSmallImage = IDB_SCE_SMALL;
  70. m_uIdBitmapSmallImageOpen = IDB_SCE_SMALL;
  71. m_uIdBitmapLargeImage = IDB_SCE_LARGE;
  72. m_crImageMask = RGB(255, 0, 255);
  73. }
  74. /////////////////////////////////////////////////////////////////////
  75. // HrLoadOleString()
  76. //
  77. // Load a string from the resource and return pointer to allocated
  78. // OLE string.
  79. //
  80. // HISTORY
  81. // 29-Jul-97 t-danm Creation.
  82. //
  83. HRESULT
  84. HrLoadOleString(
  85. UINT uStringId, // IN: String Id to load from the resource
  86. OUT LPOLESTR * ppaszOleString) // OUT: Pointer to pointer to allocated OLE string
  87. {
  88. if (ppaszOleString == NULL) {
  89. TRACE0("HrLoadOleString() - ppaszOleString is NULL.\n");
  90. return E_POINTER;
  91. }
  92. CString strT; // Temporary string
  93. AFX_MANAGE_STATE(AfxGetStaticModuleState()); // Needed for LoadString()
  94. if( IDS_SNAPINABOUT_VERSION == uStringId ) //Raid #402163
  95. {
  96. strT = OUT_VERSION;
  97. }
  98. else
  99. {
  100. if( IDS_SNAPINABOUT_PROVIDER == uStringId )
  101. {
  102. strT = OUT_PROVIDER;
  103. }
  104. else
  105. {
  106. VERIFY( strT.LoadString(uStringId) );
  107. }
  108. }
  109. *ppaszOleString = reinterpret_cast<LPOLESTR>
  110. (CoTaskMemAlloc((strT.GetLength() + 1)* sizeof(wchar_t)));
  111. if (*ppaszOleString == NULL) {
  112. return E_OUTOFMEMORY;
  113. }
  114. USES_CONVERSION;
  115. //This is a safe usage. ppaszOleString is just allocated based on the size of strT.
  116. wcscpy(OUT *ppaszOleString, T2OLE((LPTSTR)(LPCTSTR)strT));
  117. return S_OK;
  118. } // HrLoadOleString()
  119. STDMETHODIMP CAbout::GetSnapinDescription(OUT LPOLESTR __RPC_FAR *lpDescription)
  120. {
  121. return HrLoadOleString(m_uIdStrDescription, OUT lpDescription);
  122. }
  123. STDMETHODIMP CAbout::GetProvider(OUT LPOLESTR __RPC_FAR *lpName)
  124. {
  125. return HrLoadOleString(m_uIdStrProvider, OUT lpName);
  126. }
  127. STDMETHODIMP CAbout::GetSnapinVersion(OUT LPOLESTR __RPC_FAR *lpVersion)
  128. {
  129. return HrLoadOleString(m_uIdStrVersion, OUT lpVersion);
  130. }
  131. STDMETHODIMP CAbout::GetSnapinImage(OUT HICON __RPC_FAR *hAppIcon)
  132. {
  133. if (hAppIcon == NULL)
  134. return E_POINTER;
  135. AFX_MANAGE_STATE(AfxGetStaticModuleState()); // Required for AfxGetInstanceHandle()
  136. *hAppIcon = ::LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(m_uIdIconImage));
  137. if (*hAppIcon == NULL) {
  138. ASSERT(FALSE && "Unable to load icon");
  139. return E_FAIL;
  140. }
  141. return S_OK;
  142. }
  143. STDMETHODIMP CAbout::GetStaticFolderImage(
  144. OUT HBITMAP __RPC_FAR *hSmallImage,
  145. OUT HBITMAP __RPC_FAR *hSmallImageOpen,
  146. OUT HBITMAP __RPC_FAR *hLargeImage,
  147. OUT COLORREF __RPC_FAR *crMask)
  148. {
  149. //This is not a safe usage. All four pointers should be validated. Raid #550912, yanggao.
  150. ASSERT(hSmallImage != NULL);
  151. ASSERT(hSmallImageOpen != NULL);
  152. ASSERT(hLargeImage != NULL);
  153. ASSERT(crMask != NULL);
  154. if( !hSmallImage || !hSmallImageOpen || !hLargeImage || !crMask )
  155. {
  156. return E_FAIL;
  157. }
  158. AFX_MANAGE_STATE(AfxGetStaticModuleState()); // Required for AfxGetInstanceHandle()
  159. HINSTANCE hInstance = AfxGetInstanceHandle();
  160. //Raid #379315, 4/27/2001
  161. *hSmallImage = (HBITMAP)::LoadImage(
  162. hInstance,
  163. MAKEINTRESOURCE(m_uIdBitmapSmallImage),
  164. IMAGE_BITMAP,
  165. 0, 0,
  166. LR_SHARED
  167. );
  168. *hSmallImageOpen = (HBITMAP)::LoadImage(
  169. hInstance,
  170. MAKEINTRESOURCE(m_uIdBitmapSmallImageOpen),
  171. IMAGE_BITMAP,
  172. 0, 0,
  173. LR_SHARED
  174. );
  175. *hLargeImage = (HBITMAP)::LoadImage(
  176. hInstance,
  177. MAKEINTRESOURCE(m_uIdBitmapLargeImage),
  178. IMAGE_BITMAP,
  179. 0, 0,
  180. LR_SHARED
  181. );
  182. *crMask = m_crImageMask;
  183. #ifdef _DEBUG
  184. if (NULL == *hSmallImage || NULL == *hSmallImageOpen || NULL == *hLargeImage) {
  185. TRACE0("WRN: CAbout::GetStaticFolderImage() - Unable to load all the bitmaps.\n");
  186. return E_FAIL;
  187. }
  188. #endif
  189. return S_OK;
  190. }