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.

243 lines
6.9 KiB

  1. #include "precomp.h"
  2. #include <wingdi.h>
  3. ///////////////////////////////////////////////////////////////////////////////
  4. // //
  5. // CAboutIEAKSnapinExt implementation //
  6. // //
  7. ///////////////////////////////////////////////////////////////////////////////
  8. CAboutIEAKSnapinExt::CAboutIEAKSnapinExt()
  9. {
  10. InterlockedIncrement(&g_cRefThisDll);
  11. m_cRef = 1;
  12. // BUGBUG: <oliverl> need to change images here
  13. m_hSmallImage = (HBITMAP) LoadImage(g_hInstance, MAKEINTRESOURCE(IDB_IEAKSIEHELPABT_16),
  14. IMAGE_BITMAP, 16, 16, LR_DEFAULTCOLOR);
  15. m_hSmallImageOpen = m_hSmallImage;
  16. m_hLargeImage = (HBITMAP) LoadImage(g_hInstance, MAKEINTRESOURCE(IDB_IEAKSIEHELPABT_32),
  17. IMAGE_BITMAP, 32, 32, LR_DEFAULTCOLOR);
  18. m_hAppIcon = LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_HELPABOUT));
  19. }
  20. CAboutIEAKSnapinExt::~CAboutIEAKSnapinExt()
  21. {
  22. if (m_hSmallImage != NULL)
  23. DeleteObject(m_hSmallImage);
  24. if (m_hLargeImage != NULL)
  25. DeleteObject(m_hLargeImage);
  26. if (m_hAppIcon != NULL)
  27. DestroyIcon(m_hAppIcon);
  28. InterlockedDecrement(&g_cRefThisDll);
  29. }
  30. ///////////////////////////////////////////////////////////////////////////////
  31. // //
  32. // CAboutIEAKSnapinExt object implementation (IUnknown) //
  33. // //
  34. ///////////////////////////////////////////////////////////////////////////////
  35. HRESULT CAboutIEAKSnapinExt::QueryInterface (REFIID riid, void **ppv)
  36. {
  37. if (IsEqualIID(riid, IID_ISnapinAbout))
  38. {
  39. *ppv = (LPSNAPABOUT)this;
  40. m_cRef++;
  41. return S_OK;
  42. }
  43. else
  44. {
  45. *ppv = NULL;
  46. return E_NOINTERFACE;
  47. }
  48. }
  49. ULONG CAboutIEAKSnapinExt::AddRef (void)
  50. {
  51. return ++m_cRef;
  52. }
  53. ULONG CAboutIEAKSnapinExt::Release (void)
  54. {
  55. if (--m_cRef == 0) {
  56. delete this;
  57. return 0;
  58. }
  59. return m_cRef;
  60. }
  61. ///////////////////////////////////////////////////////////////////////////////
  62. // //
  63. // CAboutIEAKSnapinExt object implementation (ISnapinAbout) //
  64. // //
  65. ///////////////////////////////////////////////////////////////////////////////
  66. STDMETHODIMP CAboutIEAKSnapinExt::GetSnapinDescription(LPOLESTR *lpDescription)
  67. {
  68. LPWSTR lpBufferW;
  69. if ((lpBufferW = (LPWSTR)CoTaskMemAlloc(StrCbFromCchW(MAX_PATH))) != NULL)
  70. {
  71. LoadString (g_hInstance, IDS_SNAPIN_DESC, lpBufferW, MAX_PATH);
  72. *lpDescription = (LPOLESTR)lpBufferW;
  73. }
  74. return S_OK;
  75. }
  76. STDMETHODIMP CAboutIEAKSnapinExt::GetProvider(LPOLESTR *lpName)
  77. {
  78. LPWSTR lpBufferW;
  79. if ((lpBufferW = (LPWSTR)CoTaskMemAlloc(StrCbFromCchW(64))) != NULL)
  80. {
  81. LoadString (g_hInstance, IDS_PROVIDER_NAME, lpBufferW, 64);
  82. *lpName = (LPOLESTR)lpBufferW;
  83. }
  84. return S_OK;
  85. }
  86. STDMETHODIMP CAboutIEAKSnapinExt::GetSnapinVersion(LPOLESTR *lpVersion)
  87. {
  88. LPWSTR lpBufferW;
  89. if ((lpBufferW = (LPWSTR)CoTaskMemAlloc (StrCbFromCchW(64))) != NULL)
  90. {
  91. LoadString (g_hInstance, IDS_SNAPIN_VERSION, lpBufferW, 64);
  92. *lpVersion = (LPOLESTR)lpBufferW;
  93. }
  94. return S_OK;
  95. }
  96. STDMETHODIMP CAboutIEAKSnapinExt::GetSnapinImage(HICON *hAppIcon)
  97. {
  98. *hAppIcon = m_hAppIcon;
  99. return S_OK;
  100. }
  101. STDMETHODIMP CAboutIEAKSnapinExt::GetStaticFolderImage(HBITMAP *hSmallImage,
  102. HBITMAP *hSmallImageOpen,
  103. HBITMAP *hLargeImage,
  104. COLORREF *cMask)
  105. {
  106. *hSmallImage = m_hSmallImage;
  107. *hSmallImageOpen = m_hSmallImage;
  108. *hLargeImage = m_hLargeImage;
  109. *cMask = RGB(255, 0, 255);
  110. return S_OK;
  111. }
  112. ///////////////////////////////////////////////////////////////////////////////
  113. // //
  114. // Class factory object implementation //
  115. // //
  116. ///////////////////////////////////////////////////////////////////////////////
  117. CAboutIEAKSnapinExtCF::CAboutIEAKSnapinExtCF()
  118. {
  119. m_cRef++;
  120. InterlockedIncrement(&g_cRefThisDll);
  121. }
  122. CAboutIEAKSnapinExtCF::~CAboutIEAKSnapinExtCF()
  123. {
  124. InterlockedDecrement(&g_cRefThisDll);
  125. }
  126. ///////////////////////////////////////////////////////////////////////////////
  127. // //
  128. // Class factory object implementation (IUnknown) //
  129. // //
  130. ///////////////////////////////////////////////////////////////////////////////
  131. STDMETHODIMP_(ULONG)
  132. CAboutIEAKSnapinExtCF::AddRef()
  133. {
  134. return ++m_cRef;
  135. }
  136. STDMETHODIMP_(ULONG)
  137. CAboutIEAKSnapinExtCF::Release()
  138. {
  139. if (--m_cRef == 0)
  140. {
  141. delete this;
  142. return 0;
  143. }
  144. return m_cRef;
  145. }
  146. STDMETHODIMP
  147. CAboutIEAKSnapinExtCF::QueryInterface(REFIID riid, LPVOID FAR* ppv)
  148. {
  149. if (IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_IClassFactory))
  150. {
  151. *ppv = (LPCLASSFACTORY)this;
  152. m_cRef++;
  153. return S_OK;
  154. }
  155. else
  156. {
  157. *ppv = NULL;
  158. return E_NOINTERFACE;
  159. }
  160. }
  161. ///////////////////////////////////////////////////////////////////////////////
  162. // //
  163. // Class factory object implementation (IClassFactory) //
  164. // //
  165. ///////////////////////////////////////////////////////////////////////////////
  166. STDMETHODIMP
  167. CAboutIEAKSnapinExtCF::CreateInstance(LPUNKNOWN pUnkOuter,
  168. REFIID riid,
  169. LPVOID FAR* ppvObj)
  170. {
  171. *ppvObj = NULL;
  172. if (pUnkOuter != NULL)
  173. return CLASS_E_NOAGGREGATION;
  174. CAboutIEAKSnapinExt *pAboutGPE = new CAboutIEAKSnapinExt(); // ref count == 1
  175. if (!pAboutGPE)
  176. return E_OUTOFMEMORY;
  177. HRESULT hr = pAboutGPE->QueryInterface(riid, ppvObj);
  178. pAboutGPE->Release(); // release initial ref
  179. return hr;
  180. }
  181. STDMETHODIMP
  182. CAboutIEAKSnapinExtCF::LockServer(BOOL fLock)
  183. {
  184. UNREFERENCED_PARAMETER(fLock);
  185. return E_NOTIMPL;
  186. }