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.

171 lines
4.5 KiB

  1. //==============================================================;
  2. //
  3. // This source code is only intended as a supplement to existing Microsoft documentation.
  4. //
  5. //
  6. //
  7. //
  8. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  9. // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  10. // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
  11. // PURPOSE.
  12. //
  13. // Copyright (C) 1999 Microsoft Corporation. All Rights Reserved.
  14. //
  15. //
  16. //
  17. //==============================================================;
  18. #include "About.h"
  19. #include "resource.h"
  20. #include "globals.h"
  21. #include <crtdbg.h>
  22. CSnapinAbout::CSnapinAbout()
  23. : m_cref(0)
  24. {
  25. OBJECT_CREATED
  26. m_hSmallImage = (HBITMAP)LoadImage(g_hinst, MAKEINTRESOURCE(IDB_SMBMP), IMAGE_BITMAP, 16, 16, LR_LOADTRANSPARENT);
  27. m_hLargeImage = (HBITMAP)LoadImage(g_hinst, MAKEINTRESOURCE(IDB_LGBMP), IMAGE_BITMAP, 32, 32, LR_LOADTRANSPARENT);
  28. m_hSmallImageOpen = (HBITMAP)LoadImage(g_hinst, MAKEINTRESOURCE(IDB_SMOPEN), IMAGE_BITMAP, 16, 16, LR_LOADTRANSPARENT);
  29. m_hAppIcon = LoadIcon(g_hinst, MAKEINTRESOURCE(IDI_ICON1));
  30. }
  31. CSnapinAbout::~CSnapinAbout()
  32. {
  33. if (m_hSmallImage != NULL)
  34. FreeResource(m_hSmallImage);
  35. if (m_hLargeImage != NULL)
  36. FreeResource(m_hLargeImage);
  37. if (m_hSmallImageOpen != NULL)
  38. FreeResource(m_hSmallImageOpen);
  39. if (m_hAppIcon != NULL)
  40. FreeResource(m_hAppIcon);
  41. m_hSmallImage = NULL;
  42. m_hLargeImage = NULL;
  43. m_hSmallImageOpen = NULL;
  44. m_hAppIcon = NULL;
  45. OBJECT_DESTROYED
  46. }
  47. ///////////////////////
  48. // IUnknown implementation
  49. ///////////////////////
  50. STDMETHODIMP CSnapinAbout::QueryInterface(REFIID riid, LPVOID *ppv)
  51. {
  52. if (!ppv)
  53. return E_FAIL;
  54. *ppv = NULL;
  55. if (IsEqualIID(riid, IID_IUnknown))
  56. *ppv = static_cast<ISnapinAbout *>(this);
  57. else if (IsEqualIID(riid, IID_ISnapinAbout))
  58. *ppv = static_cast<ISnapinAbout *>(this);
  59. if (*ppv)
  60. {
  61. reinterpret_cast<IUnknown *>(*ppv)->AddRef();
  62. return S_OK;
  63. }
  64. return E_NOINTERFACE;
  65. }
  66. STDMETHODIMP_(ULONG) CSnapinAbout::AddRef()
  67. {
  68. return InterlockedIncrement((LONG *)&m_cref);
  69. }
  70. STDMETHODIMP_(ULONG) CSnapinAbout::Release()
  71. {
  72. if (InterlockedDecrement((LONG *)&m_cref) == 0)
  73. {
  74. // we need to decrement our object count in the DLL
  75. delete this;
  76. return 0;
  77. }
  78. return m_cref;
  79. }
  80. ///////////////////////////////
  81. // Interface ISnapinAbout
  82. ///////////////////////////////
  83. STDMETHODIMP CSnapinAbout::GetSnapinDescription(
  84. /* [out] */ LPOLESTR *lpDescription)
  85. {
  86. _TCHAR szDesc[MAX_PATH];
  87. LoadString(g_hinst, IDS_SNAPINDESC, szDesc, sizeof(szDesc));
  88. return AllocOleStr(lpDescription, szDesc);
  89. }
  90. STDMETHODIMP CSnapinAbout::GetProvider(
  91. /* [out] */ LPOLESTR *lpName)
  92. {
  93. return AllocOleStr(lpName, _T("Copyright � 1998 Microsoft Corporation"));;
  94. }
  95. STDMETHODIMP CSnapinAbout::GetSnapinVersion(
  96. /* [out] */ LPOLESTR *lpVersion)
  97. {
  98. return AllocOleStr(lpVersion, _T("1.0"));;
  99. }
  100. STDMETHODIMP CSnapinAbout::GetSnapinImage(
  101. /* [out] */ HICON *hAppIcon)
  102. {
  103. *hAppIcon = m_hAppIcon;
  104. if (*hAppIcon == NULL)
  105. return E_FAIL;
  106. else
  107. return S_OK;
  108. }
  109. STDMETHODIMP CSnapinAbout::GetStaticFolderImage(
  110. /* [out] */ HBITMAP *hSmallImage,
  111. /* [out] */ HBITMAP *hSmallImageOpen,
  112. /* [out] */ HBITMAP *hLargeImage,
  113. /* [out] */ COLORREF *cMask)
  114. {
  115. *hSmallImage = m_hSmallImage;
  116. *hLargeImage = m_hLargeImage;
  117. *hSmallImageOpen = m_hSmallImageOpen;
  118. *cMask = RGB(0, 128, 128);
  119. if (*hSmallImage == NULL || *hLargeImage == NULL || *hSmallImageOpen == NULL)
  120. return E_FAIL;
  121. else
  122. return S_OK;
  123. }
  124. // this allocates a chunk of memory using CoTaskMemAlloc and copies our chars into it
  125. HRESULT CSnapinAbout::AllocOleStr(LPOLESTR *lpDest, _TCHAR *szBuffer)
  126. {
  127. MAKE_WIDEPTR_FROMTSTR_ALLOC(wszStr, szBuffer);
  128. *lpDest = wszStr;
  129. return S_OK;
  130. }