Source code of Windows XP (NT5)
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.

130 lines
4.1 KiB

  1. /*======================================================================================//
  2. | Windows NT Process Control //
  3. | //
  4. |Copyright (c) 1998 Sequent Computer Systems, Incorporated. All rights reserved. //
  5. | //
  6. |File Name: About.cpp //
  7. | //
  8. |Description: Implementation of ISnapinAbout Interface for ProcCon //
  9. | //
  10. |Created: Paul Skoglund 09-1998 //
  11. | //
  12. |Rev History: //
  13. | //
  14. |=======================================================================================*/
  15. #include "StdAfx.h"
  16. #include "ProcCon.h"
  17. #include "About.h"
  18. #define MAX_STR_RESOURCE_LEN (256)
  19. #define MAX_STR_RESOURCE_SIZE (sizeof(TCHAR) * MAX_STR_RESOURCE_LEN)
  20. CAbout::CAbout() : VersionObj(_Module.GetModuleInstance())
  21. {
  22. ATLTRACE( _T("CAbout::CAbout()\n") );
  23. }
  24. CAbout::~CAbout()
  25. {
  26. ATLTRACE( _T("CAbout::~CAbout()\n") );
  27. }
  28. HRESULT CAbout::WrapLoadString(LPOLESTR *ptr, int nID)
  29. {
  30. *ptr = reinterpret_cast<LPOLESTR> (CoTaskMemAlloc(MAX_STR_RESOURCE_SIZE));
  31. if (!*ptr)
  32. return E_FAIL;
  33. if (LoadString(_Module.GetResourceInstance(), nID, *ptr, MAX_STR_RESOURCE_LEN))
  34. return S_OK;
  35. CoTaskMemFree(*ptr);
  36. *ptr = NULL;
  37. return E_FAIL;
  38. }
  39. /////////////////////////////////////////////////////////////////////////////
  40. // ISnapinAbout Implementation:
  41. //
  42. STDMETHODIMP CAbout::GetSnapinDescription (LPOLESTR* lpDescription)
  43. {
  44. ATLTRACE( _T("CAbout::GetSnapinDescription()\n") );
  45. return WrapLoadString(lpDescription, IDS_DESCRIPTION);
  46. }
  47. STDMETHODIMP CAbout::GetProvider(LPOLESTR* lpName)
  48. {
  49. ATLTRACE( _T("CAbout::GetProvider()\n") );
  50. int len = (_tcslen(VersionObj.strGetCompanyName()) + 1 ) * sizeof(TCHAR);
  51. *lpName = reinterpret_cast<LPOLESTR> (CoTaskMemAlloc(len));
  52. if (!*lpName)
  53. return E_FAIL;
  54. _tcscpy(*lpName, VersionObj.strGetCompanyName());
  55. return S_OK;
  56. }
  57. STDMETHODIMP CAbout::GetSnapinVersion(LPOLESTR* lpVersion)
  58. {
  59. ATLTRACE( _T("CAbout::GetSnapinVersion()\n") );
  60. int len = (_tcslen(VersionObj.GetFileVersion()) + 1 ) * sizeof(TCHAR);
  61. len += _tcslen(VersionObj.GetFileFlags()) * sizeof(TCHAR);
  62. *lpVersion = reinterpret_cast<LPOLESTR> (CoTaskMemAlloc(len));
  63. if (!*lpVersion)
  64. return E_FAIL;
  65. _tcscpy(*lpVersion, VersionObj.GetFileVersion());
  66. _tcscat(*lpVersion, VersionObj.GetFileFlags());
  67. return S_OK;
  68. }
  69. STDMETHODIMP CAbout::GetSnapinImage(HICON* hAppIcon)
  70. {
  71. ATLTRACE( _T("CAbout::GetSnapinImage()\n") );
  72. ASSERT(hAppIcon);
  73. *hAppIcon = LoadIcon(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDI_PROCCON));
  74. ASSERT( *hAppIcon );
  75. return *hAppIcon ? S_OK : E_FAIL;
  76. }
  77. STDMETHODIMP CAbout::GetStaticFolderImage
  78. (
  79. HBITMAP* hSmallImage,
  80. HBITMAP* hSmallImageOpen,
  81. HBITMAP* hLargeImage,
  82. COLORREF* cLargeMask
  83. )
  84. {
  85. ATLTRACE( _T("CAbout::GetStaticFolderImage()\n") );
  86. if (!hSmallImage || !hSmallImageOpen || !hLargeImage || !cLargeMask)
  87. return S_FALSE;
  88. *hSmallImage = (HBITMAP) ::LoadImage(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDB_NODES_16x16), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR );
  89. ASSERT(hSmallImage);
  90. *hSmallImageOpen = (HBITMAP) ::LoadImage(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDB_NODES_16x16), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR );
  91. ASSERT(hSmallImageOpen);
  92. *hLargeImage = (HBITMAP) ::LoadImage(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDB_NODES_32x32), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR );
  93. ASSERT(hLargeImage);
  94. *cLargeMask = RGB(255,0, 255);
  95. return S_OK;
  96. }