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.

153 lines
6.5 KiB

  1. //=--------------------------------------------------------------------------=
  2. // AutoObj.H
  3. //=--------------------------------------------------------------------------=
  4. // Copyright 1995-1996 Microsoft Corporation. All Rights Reserved.
  5. //
  6. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
  7. // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
  8. // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  9. // PARTICULAR PURPOSE.
  10. //=--------------------------------------------------------------------------=
  11. //
  12. // all of our objects will inherit from this class to share as much of the same
  13. // code as possible. this super-class contains the unknown and dispatch
  14. // implementations for them.
  15. //
  16. #ifndef _AUTOOBJ_H_
  17. // all automation objects will use the Unknown object that supports aggegation.
  18. //
  19. #include "Unknown.H"
  20. //=--------------------------------------------------------------------------=
  21. // the constants in this header file uniquely identify your automation objects.
  22. // make sure that for each object you have in the g_ObjectInfo table, you have
  23. // a constant in this header file.
  24. //
  25. #include "LocalSrv.H"
  26. #include "extobj.h"
  27. //=--------------------------------------------------------------------------=
  28. // AUTOMATIONOBJECTINFO
  29. //=--------------------------------------------------------------------------=
  30. // for each automation object type you wish to expose to the programmer/user
  31. // that is not a control, you must fill out one of these structures. if the
  32. // object isn't CoCreatable, then the first four fields should be empty.
  33. // otherwise, they should be filled in with the appropriate information.
  34. // use the macro DEFINE_AUTOMATIONOBJECT to both declare and define your object.
  35. // make sure you have an entry in the global table of objects, g_ObjectInfo
  36. // in the main .Cpp file for your InProc server.
  37. //
  38. typedef struct {
  39. UNKNOWNOBJECTINFO unknowninfo; // fill in with 0's if we're not CoCreatable
  40. long lVersion; // Version number of Object. ONLY USE IF YOU'RE CoCreatable!
  41. const IID *riid; // object's type
  42. LPCSTR pszHelpFile; // the helpfile for this automation object.
  43. ITypeInfo *pTypeInfo; // typeinfo for this object
  44. UINT cTypeInfo; // number of refs to the type info
  45. } AUTOMATIONOBJECTINFO;
  46. // macros to manipulate the AUTOMATIONOBJECTINFO in the global table table.
  47. //
  48. #define VERSIONOFOBJECT(index) ((AUTOMATIONOBJECTINFO *)(g_ObjectInfo[(index)]).pInfo)->lVersion
  49. #define INTERFACEOFOBJECT(index) *(((AUTOMATIONOBJECTINFO *)(g_ObjectInfo[(index)]).pInfo)->riid)
  50. #define PPTYPEINFOOFOBJECT(index) &((((AUTOMATIONOBJECTINFO *)(g_ObjectInfo[(index)]).pInfo)->pTypeInfo))
  51. #define PTYPEINFOOFOBJECT(index) ((AUTOMATIONOBJECTINFO *)(g_ObjectInfo[(index)]).pInfo)->pTypeInfo
  52. #define CTYPEINFOOFOBJECT(index) ((AUTOMATIONOBJECTINFO *)(g_ObjectInfo[(index)]).pInfo)->cTypeInfo
  53. #define HELPFILEOFOBJECT(index) ((AUTOMATIONOBJECTINFO *)(g_ObjectInfo[(index)]).pInfo)->pszHelpFile
  54. #ifndef INITOBJECTS
  55. #define DEFINE_AUTOMATIONOBJECT(name, clsid, objname, fn, ver, riid, pszh) \
  56. extern AUTOMATIONOBJECTINFO name##Object \
  57. #else
  58. #define DEFINE_AUTOMATIONOBJECT(name, clsid, objname, fn, ver, riid, pszh) \
  59. AUTOMATIONOBJECTINFO name##Object = { { clsid, objname, fn }, ver, riid, pszh, NULL, 0} \
  60. #endif // INITOBJECTS
  61. //=--------------------------------------------------------------------------=
  62. // Standard Dispatch and SupportErrorInfo
  63. //=--------------------------------------------------------------------------=
  64. // all objects should declare these in their class definitions so that they
  65. // get standard implementations of IDispatch and ISupportErrorInfo.
  66. //
  67. #define DECLARE_STANDARD_DISPATCH() \
  68. STDMETHOD(GetTypeInfoCount)(UINT *pctinfo) { \
  69. return CAutomationObject::GetTypeInfoCount(pctinfo); \
  70. } \
  71. STDMETHOD(GetTypeInfo)(UINT itinfo, LCID lcid, ITypeInfo **ppTypeInfoOut) { \
  72. return CAutomationObject::GetTypeInfo(itinfo, lcid, ppTypeInfoOut); \
  73. } \
  74. STDMETHOD(GetIDsOfNames)(REFIID riid, OLECHAR **rgszNames, UINT cnames, LCID lcid, DISPID *rgdispid) { \
  75. return CAutomationObject::GetIDsOfNames(riid, rgszNames, cnames, lcid, rgdispid); \
  76. } \
  77. STDMETHOD(Invoke)(DISPID dispid, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pdispparams, VARIANT *pVarResult, EXCEPINFO *pexcepinfo, UINT *puArgErr) { \
  78. return CAutomationObject::Invoke(dispid, riid, lcid, wFlags, pdispparams, pVarResult, pexcepinfo, puArgErr); \
  79. } \
  80. #define DECLARE_STANDARD_SUPPORTERRORINFO() \
  81. STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid) { \
  82. return CAutomationObject::InterfaceSupportsErrorInfo(riid); \
  83. } \
  84. enum {EXPANDO_DISABLED=FALSE, EXPANDO_ENABLED=TRUE};
  85. //=--------------------------------------------------------------------------=
  86. // CAutomationObject
  87. //=--------------------------------------------------------------------------=
  88. // global class that all automation objects can inherit from to give them a
  89. // bunch of implementation for free, namely IDispatch and ISupportsErrorInfo
  90. //
  91. //
  92. class CAutomationObject : public CUnknownObject {
  93. public:
  94. // aggreation query interface support
  95. //
  96. virtual HRESULT InternalQueryInterface(REFIID riid, void **ppvObjOut);
  97. // IDispatch methods
  98. //
  99. STDMETHOD(GetTypeInfoCount)(UINT *);
  100. STDMETHOD(GetTypeInfo)(UINT, LCID, ITypeInfo **);
  101. STDMETHOD(GetIDsOfNames)(REFIID, OLECHAR **, UINT, LCID, DISPID *);
  102. STDMETHOD(Invoke)(DISPID, REFIID, LCID, WORD, DISPPARAMS *, VARIANT *, EXCEPINFO *, UINT *);
  103. // ISupportErrorInfo methods
  104. //
  105. STDMETHOD(InterfaceSupportsErrorInfo)(REFIID);
  106. CAutomationObject(IUnknown *, int , void *, BOOL fExpandoEnabled=FALSE);
  107. virtual ~CAutomationObject();
  108. // callable functions -- things that most people will find useful.
  109. //
  110. virtual HINSTANCE GetResourceHandle(void);
  111. HRESULT Exception(HRESULT hr, WORD idException, DWORD dwHelpContextID);
  112. protected:
  113. // member variables that derived objects might need to get at information in the
  114. // global object table
  115. //
  116. int m_ObjectType;
  117. private:
  118. // member variables we don't share.
  119. //
  120. BYTE m_fLoadedTypeInfo;
  121. BYTE m_fExpandoEnabled;
  122. CExpandoObject* m_pexpando;
  123. };
  124. #define _AUTOOBJ_H_
  125. #endif // _AUTOOBJ_H_
  126.