BaseTyps.h
上传用户:dzyhzl
上传日期:2019-04-29
资源大小:56270k
文件大小:8k
源码类别:

模拟服务器

开发平台:

C/C++

  1. //+---------------------------------------------------------------------------
  2. //
  3. //  Microsoft Windows
  4. //  Copyright (c) Microsoft Corporation. All rights reserved.
  5. //
  6. //  File:       basetyps.h
  7. //
  8. //----------------------------------------------------------------------------
  9. #if !defined( _BASETYPS_H_ )
  10. #define _BASETYPS_H_
  11. #if _MSC_VER > 1000
  12. #pragma once
  13. #endif
  14. // Common macros gleamed from COMPOBJ.H
  15. #ifdef __cplusplus
  16.     #define EXTERN_C    extern "C"
  17. #else
  18.     #define EXTERN_C    extern
  19. #endif
  20. #ifdef _WIN32
  21. // Win32 doesn't support __export
  22. #define STDMETHODCALLTYPE       __stdcall
  23. #define STDMETHODVCALLTYPE      __cdecl
  24. #define STDAPICALLTYPE          __stdcall
  25. #define STDAPIVCALLTYPE         __cdecl
  26. #else
  27. #define STDMETHODCALLTYPE       __export __stdcall
  28. #define STDMETHODVCALLTYPE      __export __cdecl
  29. #define STDAPICALLTYPE          __export __stdcall
  30. #define STDAPIVCALLTYPE         __export __cdecl
  31. #endif
  32. #define STDAPI                  EXTERN_C HRESULT STDAPICALLTYPE
  33. #define STDAPI_(type)           EXTERN_C type STDAPICALLTYPE
  34. #define STDMETHODIMP            HRESULT STDMETHODCALLTYPE
  35. #define STDMETHODIMP_(type)     type STDMETHODCALLTYPE
  36. // The 'V' versions allow Variable Argument lists.
  37. #define STDAPIV                 EXTERN_C HRESULT STDAPIVCALLTYPE
  38. #define STDAPIV_(type)          EXTERN_C type STDAPIVCALLTYPE
  39. #define STDMETHODIMPV           HRESULT STDMETHODVCALLTYPE
  40. #define STDMETHODIMPV_(type)    type STDMETHODVCALLTYPE
  41. /****** Interface Declaration ***********************************************/
  42. /*
  43.  *      These are macros for declaring interfaces.  They exist so that
  44.  *      a single definition of the interface is simulataneously a proper
  45.  *      declaration of the interface structures (C++ abstract classes)
  46.  *      for both C and C++.
  47.  *
  48.  *      DECLARE_INTERFACE(iface) is used to declare an interface that does
  49.  *      not derive from a base interface.
  50.  *      DECLARE_INTERFACE_(iface, baseiface) is used to declare an interface
  51.  *      that does derive from a base interface.
  52.  *
  53.  *      By default if the source file has a .c extension the C version of
  54.  *      the interface declaratations will be expanded; if it has a .cpp
  55.  *      extension the C++ version will be expanded. if you want to force
  56.  *      the C version expansion even though the source file has a .cpp
  57.  *      extension, then define the macro "CINTERFACE".
  58.  *      eg.     cl -DCINTERFACE file.cpp
  59.  *
  60.  *      Example Interface declaration:
  61.  *
  62.  *          #undef  INTERFACE
  63.  *          #define INTERFACE   IClassFactory
  64.  *
  65.  *          DECLARE_INTERFACE_(IClassFactory, IUnknown)
  66.  *          {
  67.  *              // *** IUnknown methods ***
  68.  *              STDMETHOD(QueryInterface) (THIS_
  69.  *                                        REFIID riid,
  70.  *                                        LPVOID FAR* ppvObj) PURE;
  71.  *              STDMETHOD_(ULONG,AddRef) (THIS) PURE;
  72.  *              STDMETHOD_(ULONG,Release) (THIS) PURE;
  73.  *
  74.  *              // *** IClassFactory methods ***
  75.  *              STDMETHOD(CreateInstance) (THIS_
  76.  *                                        LPUNKNOWN pUnkOuter,
  77.  *                                        REFIID riid,
  78.  *                                        LPVOID FAR* ppvObject) PURE;
  79.  *          };
  80.  *
  81.  *      Example C++ expansion:
  82.  *
  83.  *          struct FAR IClassFactory : public IUnknown
  84.  *          {
  85.  *              virtual HRESULT STDMETHODCALLTYPE QueryInterface(
  86.  *                                                  IID FAR& riid,
  87.  *                                                  LPVOID FAR* ppvObj) = 0;
  88.  *              virtual HRESULT STDMETHODCALLTYPE AddRef(void) = 0;
  89.  *              virtual HRESULT STDMETHODCALLTYPE Release(void) = 0;
  90.  *              virtual HRESULT STDMETHODCALLTYPE CreateInstance(
  91.  *                                              LPUNKNOWN pUnkOuter,
  92.  *                                              IID FAR& riid,
  93.  *                                              LPVOID FAR* ppvObject) = 0;
  94.  *          };
  95.  *
  96.  *          NOTE: Our documentation says '#define interface class' but we use
  97.  *          'struct' instead of 'class' to keep a lot of 'public:' lines
  98.  *          out of the interfaces.  The 'FAR' forces the 'this' pointers to
  99.  *          be far, which is what we need.
  100.  *
  101.  *      Example C expansion:
  102.  *
  103.  *          typedef struct IClassFactory
  104.  *          {
  105.  *              const struct IClassFactoryVtbl FAR* lpVtbl;
  106.  *          } IClassFactory;
  107.  *
  108.  *          typedef struct IClassFactoryVtbl IClassFactoryVtbl;
  109.  *
  110.  *          struct IClassFactoryVtbl
  111.  *          {
  112.  *              HRESULT (STDMETHODCALLTYPE * QueryInterface) (
  113.  *                                                  IClassFactory FAR* This,
  114.  *                                                  IID FAR* riid,
  115.  *                                                  LPVOID FAR* ppvObj) ;
  116.  *              HRESULT (STDMETHODCALLTYPE * AddRef) (IClassFactory FAR* This) ;
  117.  *              HRESULT (STDMETHODCALLTYPE * Release) (IClassFactory FAR* This) ;
  118.  *              HRESULT (STDMETHODCALLTYPE * CreateInstance) (
  119.  *                                                  IClassFactory FAR* This,
  120.  *                                                  LPUNKNOWN pUnkOuter,
  121.  *                                                  IID FAR* riid,
  122.  *                                                  LPVOID FAR* ppvObject);
  123.  *              HRESULT (STDMETHODCALLTYPE * LockServer) (
  124.  *                                                  IClassFactory FAR* This,
  125.  *                                                  BOOL fLock);
  126.  *          };
  127.  */
  128. #if defined(__cplusplus) && !defined(CINTERFACE)
  129. //#define interface               struct FAR
  130. #define interface struct
  131. #define STDMETHOD(method)       virtual HRESULT STDMETHODCALLTYPE method
  132. #define STDMETHOD_(type,method) virtual type STDMETHODCALLTYPE method
  133. #define STDMETHODV(method)       virtual HRESULT STDMETHODVCALLTYPE method
  134. #define STDMETHODV_(type,method) virtual type STDMETHODVCALLTYPE method
  135. #define PURE                    = 0
  136. #define THIS_
  137. #define THIS                    void
  138. #define DECLARE_INTERFACE(iface)    interface DECLSPEC_NOVTABLE iface
  139. #define DECLARE_INTERFACE_(iface, baseiface)    interface DECLSPEC_NOVTABLE iface : public baseiface
  140. #else
  141. #define interface               struct
  142. #define STDMETHOD(method)       HRESULT (STDMETHODCALLTYPE * method)
  143. #define STDMETHOD_(type,method) type (STDMETHODCALLTYPE * method)
  144. #define STDMETHODV(method)       HRESULT (STDMETHODVCALLTYPE * method)
  145. #define STDMETHODV_(type,method) type (STDMETHODVCALLTYPE * method)
  146. #define PURE
  147. #define THIS_                   INTERFACE FAR* This,
  148. #define THIS                    INTERFACE FAR* This
  149. #ifdef CONST_VTABLE
  150. #define DECLARE_INTERFACE(iface)    typedef interface iface { 
  151.                                     const struct iface##Vtbl FAR* lpVtbl; 
  152.                                 } iface; 
  153.                                 typedef const struct iface##Vtbl iface##Vtbl; 
  154.                                 const struct iface##Vtbl
  155. #else
  156. #define DECLARE_INTERFACE(iface)    typedef interface iface { 
  157.                                     struct iface##Vtbl FAR* lpVtbl; 
  158.                                 } iface; 
  159.                                 typedef struct iface##Vtbl iface##Vtbl; 
  160.                                 struct iface##Vtbl
  161. #endif
  162. #define DECLARE_INTERFACE_(iface, baseiface)    DECLARE_INTERFACE(iface)
  163. #endif
  164. #include <guiddef.h>
  165. #ifndef _ERROR_STATUS_T_DEFINED
  166. typedef unsigned long error_status_t;
  167. #define _ERROR_STATUS_T_DEFINED
  168. #endif
  169. #ifndef _WCHAR_T_DEFINED
  170. typedef unsigned short wchar_t;
  171. #define _WCHAR_T_DEFINED
  172. #endif
  173. #endif