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.

62 lines
2.1 KiB

  1. #ifndef __DISPTCH2_H__
  2. #define __DISPTCH2_H__
  3. #include "dispatch.h"
  4. #include "asptxn.h"
  5. template <class T>
  6. class ATL_NO_VTABLE CDispatchImpl : public T
  7. {
  8. public:
  9. // IDispatch
  10. STDMETHOD(GetTypeInfoCount)(UINT* pctinfo)
  11. {
  12. *pctinfo = 1;
  13. return S_OK;
  14. }
  15. STDMETHOD(GetTypeInfo)(UINT itinfo, LCID lcid, ITypeInfo** pptinfo)
  16. {
  17. return gm_tih.GetTypeInfo(itinfo, lcid, pptinfo);
  18. }
  19. STDMETHOD(GetIDsOfNames)(REFIID riid, LPOLESTR* rgszNames, UINT cNames,
  20. LCID lcid, DISPID* rgdispid)
  21. {
  22. return gm_tih.GetIDsOfNames(riid, rgszNames, cNames, lcid, rgdispid);
  23. }
  24. STDMETHOD(Invoke)(DISPID dispidMember, REFIID riid,
  25. LCID lcid, WORD wFlags, DISPPARAMS* pdispparams, VARIANT* pvarResult,
  26. EXCEPINFO* pexcepinfo, UINT* puArgErr)
  27. {
  28. // VBScript does not distinguish between a propget and a method
  29. // implement that behavior for other languages.
  30. //
  31. if (wFlags & (DISPATCH_METHOD | DISPATCH_PROPERTYGET))
  32. wFlags |= DISPATCH_METHOD | DISPATCH_PROPERTYGET;
  33. return gm_tih.Invoke((IDispatch*)this, dispidMember, riid, lcid,
  34. wFlags, pdispparams, pvarResult, pexcepinfo,
  35. puArgErr);
  36. }
  37. protected:
  38. static CComTypeInfoHolder gm_tih;
  39. static HRESULT GetTI(LCID lcid, ITypeInfo** ppInfo)
  40. {
  41. return gm_tih.GetTI(lcid, ppInfo);
  42. }
  43. };
  44. typedef CDispatchImpl<IApplicationObject> IApplicationObjectImpl;
  45. typedef CDispatchImpl<IASPError> IASPErrorImpl;
  46. typedef CDispatchImpl<IReadCookie> IReadCookieImpl;
  47. typedef CDispatchImpl<IRequest> IRequestImpl;
  48. typedef CDispatchImpl<IRequestDictionary> IRequestDictionaryImpl;
  49. typedef CDispatchImpl<IResponse> IResponseImpl;
  50. typedef CDispatchImpl<IScriptingContext> IScriptingContextImpl;
  51. typedef CDispatchImpl<IServer> IServerImpl;
  52. typedef CDispatchImpl<ISessionObject> ISessionObjectImpl;
  53. typedef CDispatchImpl<IStringList> IStringListImpl;
  54. typedef CDispatchImpl<IVariantDictionary> IVariantDictionaryImpl;
  55. typedef CDispatchImpl<IWriteCookie> IWriteCookieImpl;
  56. typedef CDispatchImpl<IASPObjectContext> IASPObjectContextImpl;
  57. #endif // __DISPTCH2_H__