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.

258 lines
7.0 KiB

  1. //*************************************************************
  2. // File name: ABOUT.CPP
  3. //
  4. // Description: About information for the Group Policy Editor
  5. //
  6. //
  7. // Microsoft Confidential
  8. // Copyright (c) Microsoft Corporation 1998
  9. // All rights reserved
  10. //
  11. //*************************************************************
  12. #include "main.h"
  13. ///////////////////////////////////////////////////////////////////////////////
  14. // //
  15. // CAboutGPE implementation //
  16. // //
  17. ///////////////////////////////////////////////////////////////////////////////
  18. CAboutGPE::CAboutGPE(BOOL fRSOP) : m_smallImage( 0 ), m_largeImage( 0 )
  19. {
  20. m_fRSOP = fRSOP;
  21. InterlockedIncrement(&g_cRefThisDll);
  22. m_cRef = 1;
  23. }
  24. CAboutGPE::~CAboutGPE()
  25. {
  26. InterlockedDecrement(&g_cRefThisDll);
  27. if ( m_smallImage )
  28. {
  29. DeleteObject( m_smallImage );
  30. }
  31. if ( m_largeImage )
  32. {
  33. DeleteObject( m_largeImage );
  34. }
  35. }
  36. ///////////////////////////////////////////////////////////////////////////////
  37. // //
  38. // CAboutGPE object implementation (IUnknown) //
  39. // //
  40. ///////////////////////////////////////////////////////////////////////////////
  41. HRESULT CAboutGPE::QueryInterface (REFIID riid, void **ppv)
  42. {
  43. if (IsEqualIID(riid, IID_ISnapinAbout))
  44. {
  45. *ppv = (LPSNAPABOUT)this;
  46. m_cRef++;
  47. return S_OK;
  48. }
  49. else
  50. {
  51. *ppv = NULL;
  52. return E_NOINTERFACE;
  53. }
  54. }
  55. ULONG CAboutGPE::AddRef (void)
  56. {
  57. return ++m_cRef;
  58. }
  59. ULONG CAboutGPE::Release (void)
  60. {
  61. if (--m_cRef == 0) {
  62. delete this;
  63. return 0;
  64. }
  65. return m_cRef;
  66. }
  67. ///////////////////////////////////////////////////////////////////////////////
  68. // //
  69. // CAboutGPE object implementation (ISnapinAbout) //
  70. // //
  71. ///////////////////////////////////////////////////////////////////////////////
  72. STDMETHODIMP CAboutGPE::GetSnapinDescription(LPOLESTR *lpDescription)
  73. {
  74. LPTSTR lpBuffer;
  75. lpBuffer = (LPTSTR) CoTaskMemAlloc (256 * sizeof(TCHAR));
  76. if (lpBuffer)
  77. {
  78. LoadString (g_hInstance, m_fRSOP? IDS_RSOP_SNAPIN_DESCRIPT : IDS_SNAPIN_DESCRIPT, lpBuffer, 256);
  79. *lpDescription = lpBuffer;
  80. }
  81. return S_OK;
  82. }
  83. STDMETHODIMP CAboutGPE::GetProvider(LPOLESTR *lpName)
  84. {
  85. LPTSTR lpBuffer;
  86. lpBuffer = (LPTSTR) CoTaskMemAlloc (50 * sizeof(TCHAR));
  87. if (lpBuffer)
  88. {
  89. LoadString (g_hInstance, IDS_PROVIDER_NAME, lpBuffer, 50);
  90. *lpName = lpBuffer;
  91. }
  92. return S_OK;
  93. }
  94. STDMETHODIMP CAboutGPE::GetSnapinVersion(LPOLESTR *lpVersion)
  95. {
  96. LPTSTR lpBuffer;
  97. lpBuffer = (LPTSTR) CoTaskMemAlloc (50 * sizeof(TCHAR));
  98. if (lpBuffer)
  99. {
  100. LoadString (g_hInstance, IDS_SNAPIN_VERSION, lpBuffer, 50);
  101. *lpVersion = lpBuffer;
  102. }
  103. return S_OK;
  104. }
  105. STDMETHODIMP CAboutGPE::GetSnapinImage(HICON *hAppIcon)
  106. {
  107. *hAppIcon = LoadIcon (g_hInstance, MAKEINTRESOURCE(IDI_POLICY));
  108. return S_OK;
  109. }
  110. STDMETHODIMP CAboutGPE::GetStaticFolderImage(HBITMAP *hSmallImage,
  111. HBITMAP *hSmallImageOpen,
  112. HBITMAP *hLargeImage,
  113. COLORREF *cMask)
  114. {
  115. if ( !m_smallImage )
  116. {
  117. m_smallImage = (HBITMAP) LoadImage (g_hInstance, MAKEINTRESOURCE(IDB_POLICY16),
  118. IMAGE_BITMAP,
  119. 16, 16, LR_DEFAULTCOLOR);
  120. }
  121. if ( !m_largeImage )
  122. {
  123. m_largeImage = (HBITMAP) LoadImage (g_hInstance, MAKEINTRESOURCE(IDB_POLICY32),
  124. IMAGE_BITMAP,
  125. 32, 32, LR_DEFAULTCOLOR);
  126. }
  127. *hLargeImage = m_largeImage;
  128. *hSmallImage = *hSmallImageOpen = m_smallImage;
  129. *cMask = RGB(255,0,255);
  130. return S_OK;
  131. }
  132. ///////////////////////////////////////////////////////////////////////////////
  133. // //
  134. // Class factory object implementation //
  135. // //
  136. ///////////////////////////////////////////////////////////////////////////////
  137. CAboutGPECF::CAboutGPECF(BOOL fRSOP)
  138. {
  139. m_fRSOP = fRSOP;
  140. m_cRef = 1;
  141. InterlockedIncrement(&g_cRefThisDll);
  142. }
  143. CAboutGPECF::~CAboutGPECF()
  144. {
  145. InterlockedDecrement(&g_cRefThisDll);
  146. }
  147. ///////////////////////////////////////////////////////////////////////////////
  148. // //
  149. // Class factory object implementation (IUnknown) //
  150. // //
  151. ///////////////////////////////////////////////////////////////////////////////
  152. STDMETHODIMP_(ULONG)
  153. CAboutGPECF::AddRef()
  154. {
  155. return ++m_cRef;
  156. }
  157. STDMETHODIMP_(ULONG)
  158. CAboutGPECF::Release()
  159. {
  160. if (--m_cRef == 0)
  161. {
  162. delete this;
  163. return 0;
  164. }
  165. return m_cRef;
  166. }
  167. STDMETHODIMP
  168. CAboutGPECF::QueryInterface(REFIID riid, LPVOID FAR* ppv)
  169. {
  170. if (IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_IClassFactory))
  171. {
  172. *ppv = (LPCLASSFACTORY)this;
  173. m_cRef++;
  174. return S_OK;
  175. }
  176. else
  177. {
  178. *ppv = NULL;
  179. return E_NOINTERFACE;
  180. }
  181. }
  182. ///////////////////////////////////////////////////////////////////////////////
  183. // //
  184. // Class factory object implementation (IClassFactory) //
  185. // //
  186. ///////////////////////////////////////////////////////////////////////////////
  187. STDMETHODIMP
  188. CAboutGPECF::CreateInstance(LPUNKNOWN pUnkOuter,
  189. REFIID riid,
  190. LPVOID FAR* ppvObj)
  191. {
  192. *ppvObj = NULL;
  193. if (pUnkOuter)
  194. return CLASS_E_NOAGGREGATION;
  195. CAboutGPE *pAboutGPE = new CAboutGPE(m_fRSOP); // ref count == 1
  196. if (!pAboutGPE)
  197. return E_OUTOFMEMORY;
  198. HRESULT hr = pAboutGPE->QueryInterface(riid, ppvObj);
  199. pAboutGPE->Release(); // release initial ref
  200. return hr;
  201. }
  202. STDMETHODIMP
  203. CAboutGPECF::LockServer(BOOL fLock)
  204. {
  205. return E_NOTIMPL;
  206. }