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.

168 lines
4.2 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. StdAfx.h
  5. Abstract:
  6. This module contains the definitions for the base
  7. ATL methods.
  8. Author:
  9. Don Dumitru (dondu@microsoft.com)
  10. Revision History:
  11. dondu 12/04/96 created
  12. --*/
  13. // stdafx.h : include file for standard system include files,
  14. // or project specific include files that are used frequently,
  15. // but are changed infrequently
  16. #ifndef _WIN32_WINNT
  17. #define _WIN32_WINNT 0x0400
  18. #endif
  19. #ifdef _ATL_NO_DEBUG_CRT
  20. #include <nt.h>
  21. #include <ntrtl.h>
  22. #include <nturtl.h>
  23. #include <windows.h>
  24. #include "dbgtrace.h"
  25. #define _ASSERTE _ASSERT
  26. #endif
  27. //#define _ATL_APARTMENT_THREADED
  28. #include <atlbase.h>
  29. //You may derive a class from CComModule and use it if you want to override
  30. //something, but do not change the name of _Module
  31. extern CComModule _Module;
  32. #include <atlcom.h>
  33. #if defined(_ATL_SINGLE_THREADED)
  34. #define ATL_THREADING_MODEL_VALUE L"Single"
  35. #elif defined(_ATL_APARTMENT_THREADED)
  36. #define ATL_THREADING_MODEL_VALUE L"Apartment"
  37. #else
  38. #define ATL_THREADING_MODEL_VALUE L"Both"
  39. #endif
  40. #define DECLARE_REGISTRY_RESOURCEID_EX(x,desc,progid,viprogid) \
  41. static HRESULT WINAPI UpdateRegistry(BOOL bRegister) { \
  42. HRESULT hrRes; \
  43. _ATL_REGMAP_ENTRY *parme; \
  44. \
  45. hrRes = AtlAllocRegMapEx(&parme, \
  46. &GetObjectCLSID(), \
  47. &_Module, \
  48. NULL, \
  49. L"DESCRIPTION", \
  50. desc, \
  51. L"PROGID", \
  52. progid, \
  53. L"VIPROGID", \
  54. viprogid, \
  55. L"THREADINGMODEL", \
  56. ATL_THREADING_MODEL_VALUE, \
  57. NULL, \
  58. NULL); \
  59. if (!SUCCEEDED(hrRes)) { \
  60. return (hrRes); \
  61. } \
  62. hrRes = _Module.UpdateRegistryFromResource(x,bRegister,parme); \
  63. CoTaskMemFree(parme); \
  64. return (hrRes); \
  65. }
  66. #define DECLARE_REGISTRY_RESOURCE_EX(x,desc,progid,viprogid) \
  67. static HRESULT WINAPI UpdateRegistry(BOOL bRegister) { \
  68. HRESULT hrRes; \
  69. _ATL_REGMAP_ENTRY *parme; \
  70. \
  71. hrRes = AtlAllocRegMapEx(&parme, \
  72. &GetObjectCLSID(), \
  73. &_Module, \
  74. NULL, \
  75. L"DESCRIPTION", \
  76. desc, \
  77. L"PROGID", \
  78. progid, \
  79. L"VIPROGID", \
  80. viprogid, \
  81. L"THREADINGMODEL", \
  82. ATL_THREADING_MODEL_VALUE, \
  83. NULL, \
  84. NULL); \
  85. if (!SUCCEEDED(hrRes)) { \
  86. return (hrRes); \
  87. } \
  88. hrRes = _Module.UpdateRegistryFromResource(_T(#x),bRegister,parme); \
  89. CoTaskMemFree(parme); \
  90. return (hrRes); \
  91. }
  92. HRESULT AtlAllocRegMapEx(_ATL_REGMAP_ENTRY **pparmeResult,
  93. const CLSID *pclsid,
  94. CComModule *pmodule,
  95. LPCOLESTR pszIndex,
  96. ...);
  97. template <class Base>
  98. HRESULT AtlCreateInstanceOf(IUnknown *pUnkOuter, CComObject<Base> **pp) {
  99. // template <class Base>
  100. // HRESULT WINAPI CComObject<Base>::CreateInstance(CComObject<Base>** pp)
  101. // {
  102. _ASSERTE(pp != NULL);
  103. HRESULT hRes = E_OUTOFMEMORY;
  104. CComObject<Base>* p = NULL;
  105. ATLTRY(p = new CComObject<Base>())
  106. if (p != NULL)
  107. {
  108. // p->SetVoid(NULL); // Change this...
  109. p->SetVoid(pUnkOuter); // ... to this.
  110. p->InternalFinalConstructAddRef();
  111. hRes = p->FinalConstruct();
  112. p->InternalFinalConstructRelease();
  113. if (hRes != S_OK)
  114. {
  115. delete p;
  116. p = NULL;
  117. }
  118. }
  119. *pp = p;
  120. return hRes;
  121. // }
  122. }
  123. template <class Base>
  124. HRESULT AtlCreateInstanceOf(IUnknown *pUnkOuter, REFIID iidDesired, LPVOID *pp) {
  125. HRESULT hrRes;
  126. CComObject<Base> *p = NULL;
  127. _ASSERTE(pp != NULL);
  128. *pp = NULL;
  129. hrRes = AtlCreateInstanceOf(pUnkOuter,&p);
  130. if (SUCCEEDED(hrRes)) {
  131. _ASSERTE(p != NULL);
  132. p->AddRef();
  133. hrRes = p->QueryInterface(iidDesired,pp);
  134. p->Release();
  135. }
  136. return (hrRes);
  137. }