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.

238 lines
6.5 KiB

  1. // SnapinAbout.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "SnapinAbout.h"
  5. #include "FileVersion.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CSnapinAbout
  13. IMPLEMENT_DYNCREATE(CSnapinAbout, CCmdTarget)
  14. CSnapinAbout::CSnapinAbout()
  15. {
  16. EnableAutomation();
  17. // To keep the application running as long as an OLE automation
  18. // object is active, the constructor calls AfxOleLockApp.
  19. AfxOleLockApp();
  20. }
  21. CSnapinAbout::~CSnapinAbout()
  22. {
  23. // To terminate the application when all objects created with
  24. // with OLE automation, the destructor calls AfxOleUnlockApp.
  25. AfxOleUnlockApp();
  26. }
  27. /////////////////////////////////////////////////////////////////////////////
  28. // Overrideable Members
  29. /////////////////////////////////////////////////////////////////////////////
  30. HRESULT CSnapinAbout::OnGetStaticFolderImage(HBITMAP __RPC_FAR * hSmallImage,HBITMAP __RPC_FAR * hSmallImageOpen,HBITMAP __RPC_FAR * hLargeImage,COLORREF __RPC_FAR * cMask)
  31. {
  32. TRACEX(_T("CSnapinAbout::OnGetStaticFolderImage\n"));
  33. *hSmallImage = NULL;
  34. *hSmallImageOpen = NULL;
  35. *hLargeImage = NULL;
  36. *cMask = NULL;
  37. return S_FALSE;
  38. }
  39. void CSnapinAbout::OnGetSnapinDescription(CString& sDescription)
  40. {
  41. TRACEX(_T("CSnapinAbout::OnGetSnapinDescription\n"));
  42. sDescription = _T("");
  43. }
  44. HRESULT CSnapinAbout::OnGetSnapinImage(HICON __RPC_FAR *hAppIcon)
  45. {
  46. TRACEX(_T("CSnapinAbout::OnGetSnapinImage\n"));
  47. *hAppIcon = NULL;
  48. return S_FALSE;
  49. }
  50. void CSnapinAbout::OnFinalRelease()
  51. {
  52. // When the last reference for an automation object is released
  53. // OnFinalRelease is called. The base class will automatically
  54. // deletes the object. Add additional cleanup required for your
  55. // object before calling the base class.
  56. CCmdTarget::OnFinalRelease();
  57. }
  58. BEGIN_MESSAGE_MAP(CSnapinAbout, CCmdTarget)
  59. //{{AFX_MSG_MAP(CSnapinAbout)
  60. // NOTE - the ClassWizard will add and remove mapping macros here.
  61. //}}AFX_MSG_MAP
  62. END_MESSAGE_MAP()
  63. BEGIN_DISPATCH_MAP(CSnapinAbout, CCmdTarget)
  64. //{{AFX_DISPATCH_MAP(CSnapinAbout)
  65. // NOTE - the ClassWizard will add and remove mapping macros here.
  66. //}}AFX_DISPATCH_MAP
  67. END_DISPATCH_MAP()
  68. // Note: we add support for IID_ISnapinAbout to support typesafe binding
  69. // from VBA. This IID must match the GUID that is attached to the
  70. // dispinterface in the .ODL file.
  71. // {80F85331-AB10-11D2-BD62-0000F87A3912}
  72. static const IID IID_ISnapInAbout =
  73. { 0x80f85331, 0xab10, 0x11d2, { 0xbd, 0x62, 0x0, 0x0, 0xf8, 0x7a, 0x39, 0x12 } };
  74. BEGIN_INTERFACE_MAP(CSnapinAbout, CCmdTarget)
  75. INTERFACE_PART(CSnapinAbout, IID_ISnapInAbout, Dispatch)
  76. INTERFACE_PART(CSnapinAbout, IID_ISnapinAbout, SnapinAbout)
  77. END_INTERFACE_MAP()
  78. /////////////////////////////////////////////////////////////////////////////
  79. // ISnapinAbout Interface Map
  80. /////////////////////////////////////////////////////////////////////////////
  81. ULONG FAR EXPORT CSnapinAbout::XSnapinAbout::AddRef()
  82. {
  83. METHOD_PROLOGUE(CSnapinAbout, SnapinAbout)
  84. return pThis->ExternalAddRef();
  85. }
  86. ULONG FAR EXPORT CSnapinAbout::XSnapinAbout::Release()
  87. {
  88. METHOD_PROLOGUE(CSnapinAbout, SnapinAbout)
  89. return pThis->ExternalRelease();
  90. }
  91. HRESULT FAR EXPORT CSnapinAbout::XSnapinAbout::QueryInterface(
  92. REFIID iid, void FAR* FAR* ppvObj)
  93. {
  94. METHOD_PROLOGUE(CSnapinAbout, SnapinAbout)
  95. return (HRESULT)pThis->ExternalQueryInterface(&iid, ppvObj);
  96. }
  97. HRESULT FAR EXPORT CSnapinAbout::XSnapinAbout::GetSnapinDescription(
  98. /* [out] */ LPOLESTR __RPC_FAR *lpDescription)
  99. {
  100. METHOD_PROLOGUE(CSnapinAbout, SnapinAbout)
  101. TRACEX(_T("CSnapinAbout::XSnapinAbout::GetSnapinDescription\n"));
  102. TRACEARGn(lpDescription);
  103. TCHAR szFileName[_MAX_PATH];
  104. GetModuleFileName(AfxGetInstanceHandle(),szFileName,_MAX_PATH);
  105. CFileVersion fv;
  106. fv.Open(szFileName);
  107. CString sSnapInDescription;
  108. pThis->OnGetSnapinDescription(sSnapInDescription);
  109. CString sDescription = sSnapInDescription;
  110. sDescription += _T("\r\n");
  111. sDescription += fv.GetFileDescription();
  112. sDescription += _T("\r\n");
  113. sDescription += fv.GetLegalCopyright();
  114. if( sDescription.IsEmpty() )
  115. return S_OK;
  116. LPVOID lpBuffer = CoTaskMemAlloc((sDescription.GetLength()+1)*sizeof(TCHAR));
  117. CopyMemory(lpBuffer,sDescription,(sDescription.GetLength()+1)*sizeof(TCHAR));
  118. *lpDescription = (TCHAR*)lpBuffer;
  119. return S_OK;
  120. }
  121. HRESULT FAR EXPORT CSnapinAbout::XSnapinAbout::GetProvider(
  122. /* [out] */ LPOLESTR __RPC_FAR *lpName)
  123. {
  124. METHOD_PROLOGUE(CSnapinAbout, SnapinAbout)
  125. TRACEX(_T("CSnapinAbout::XSnapinAbout::GetProvider\n"));
  126. TRACEARGn(lpName);
  127. TCHAR szFileName[_MAX_PATH];
  128. GetModuleFileName(AfxGetInstanceHandle(),szFileName,_MAX_PATH);
  129. CFileVersion fv;
  130. fv.Open(szFileName);
  131. CString sProvider = fv.GetCompanyName();
  132. if( sProvider.IsEmpty() )
  133. return S_OK;
  134. LPVOID lpBuffer = CoTaskMemAlloc((sProvider.GetLength()+1)*sizeof(TCHAR));
  135. CopyMemory(lpBuffer,sProvider,(sProvider.GetLength()+1)*sizeof(TCHAR));
  136. *lpName = (TCHAR*)lpBuffer;
  137. return S_OK;
  138. }
  139. HRESULT FAR EXPORT CSnapinAbout::XSnapinAbout::GetSnapinVersion(
  140. /* [out] */ LPOLESTR __RPC_FAR *lpVersion)
  141. {
  142. METHOD_PROLOGUE(CSnapinAbout, SnapinAbout)
  143. TRACEX(_T("CSnapinAbout::XSnapinAbout::GetSnapinVersion\n"));
  144. TRACEARGn(lpVersion);
  145. TCHAR szFileName[_MAX_PATH];
  146. GetModuleFileName(AfxGetInstanceHandle(),szFileName,_MAX_PATH);
  147. CFileVersion fv;
  148. fv.Open(szFileName);
  149. CString sVersion = fv.GetFileVersion();
  150. if( sVersion.IsEmpty() )
  151. return S_OK;
  152. LPVOID lpBuffer = CoTaskMemAlloc((sVersion.GetLength()+1)*sizeof(TCHAR));
  153. CopyMemory(lpBuffer,sVersion,(sVersion.GetLength()+1)*sizeof(TCHAR));
  154. *lpVersion = (TCHAR*)lpBuffer;
  155. return S_OK;
  156. }
  157. HRESULT FAR EXPORT CSnapinAbout::XSnapinAbout::GetSnapinImage(
  158. /* [out] */ HICON __RPC_FAR *hAppIcon)
  159. {
  160. METHOD_PROLOGUE(CSnapinAbout, SnapinAbout)
  161. TRACEX(_T("CSnapinAbout::XSnapinAbout::GetSnapinImage\n"));
  162. TRACEARGn(hAppIcon);
  163. return pThis->OnGetSnapinImage(hAppIcon);
  164. }
  165. HRESULT FAR EXPORT CSnapinAbout::XSnapinAbout::GetStaticFolderImage(
  166. /* [out] */ HBITMAP __RPC_FAR *hSmallImage,
  167. /* [out] */ HBITMAP __RPC_FAR *hSmallImageOpen,
  168. /* [out] */ HBITMAP __RPC_FAR *hLargeImage,
  169. /* [out] */ COLORREF __RPC_FAR *cMask)
  170. {
  171. METHOD_PROLOGUE(CSnapinAbout, SnapinAbout)
  172. TRACEX(_T("CSnapinAbout::XSnapinAbout::GetStaticFolderImage\n"));
  173. TRACEARGn(hSmallImage);
  174. TRACEARGn(hSmallImageOpen);
  175. TRACEARGn(hLargeImage);
  176. TRACEARGn(cMask);
  177. return pThis->OnGetStaticFolderImage(hSmallImage,hSmallImageOpen,hLargeImage,cMask);
  178. }
  179. /////////////////////////////////////////////////////////////////////////////
  180. // CSnapinAbout message handlers