BEEPER.H
上传用户:bangxh
上传日期:2007-01-31
资源大小:42235k
文件大小:4k
源码类别:

Windows编程

开发平台:

Visual C++

  1. /*
  2.  * BEEPER.H
  3.  * Beeper Automation Object #4 Chapter 14
  4.  *
  5.  * Classes that implement the Beeper object.
  6.  *
  7.  * Copyright (c)1993-1995 Microsoft Corporation, All Right Reserved
  8.  *
  9.  * Kraig Brockschmidt, Microsoft
  10.  * Internet  :  kraigb@microsoft.com
  11.  * Compuserve:  >INTERNET:kraigb@microsoft.com
  12.  */
  13. #ifndef _BEEPER_H_
  14. #define _BEEPER_H_
  15. /*
  16.  * This #define tells <bookguid.h> to not define GUIDs that will
  17.  * be defined in MKTYPLIB-generated header files, like ibeeper.h.
  18.  */
  19. #define GUIDS_FROM_TYPELIB
  20. #define INC_AUTOMATION
  21. #define CHAPTER14
  22. #include <inole.h>
  23. #include <malloc.h>
  24. //This file is generated from MKTYPLIB
  25. #include "ibeeper.h"
  26. //This one isn't defined in ibeeper.h
  27. DEFINE_GUID(DIID_DIBeeper,0x0002115D,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
  28. //Help context ID for exceptions
  29. #define HID_SOUND_PROPERTY_LIMITATIONS  0x1E100
  30. //English exception strings
  31. #define IDS_0_MIN                   16
  32. #define IDS_0_EXCEPTIONSOURCE       (IDS_0_MIN)
  33. #define IDS_0_EXCEPTIONINVALIDSOUND (IDS_0_MIN+1)
  34. //German exception strings
  35. #define IDS_7_MIN                   32
  36. #define IDS_7_EXCEPTIONSOURCE       (IDS_7_MIN)
  37. #define IDS_7_EXCEPTIONINVALIDSOUND (IDS_7_MIN+1)
  38. //Forward class declarations for friend statements
  39. class CImpISupportErrorInfo;
  40. typedef CImpISupportErrorInfo *PCImpISupportErrorInfo;
  41. class CBeeper : public IBeeper
  42.     {
  43.     protected:
  44.         ULONG           m_cRef;             //Object reference count
  45.         LPUNKNOWN       m_pUnkOuter;        //Controlling unknown
  46.         PFNDESTROYED    m_pfnDestroy;       //To call on closure
  47.         long            m_lSound;
  48.         //Our interfaces
  49.         PCImpISupportErrorInfo m_pImpISuppErr;
  50.         ITypeInfo      *m_pITINeutral;      //Type information
  51.         ITypeInfo      *m_pITIGerman;
  52.     public:
  53.         CBeeper(LPUNKNOWN, PFNDESTROYED);
  54.         ~CBeeper(void);
  55.         BOOL         Init(void);
  56.         void         Exception(WORD);
  57.         //Non-delegating object IUnknown
  58.         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
  59.         STDMETHODIMP_(ULONG) AddRef(void);
  60.         STDMETHODIMP_(ULONG) Release(void);
  61.         //IDispatch members
  62.         STDMETHODIMP GetTypeInfoCount(UINT *);
  63.         STDMETHODIMP GetTypeInfo(UINT, LCID, ITypeInfo **);
  64.         STDMETHODIMP GetIDsOfNames(REFIID, OLECHAR **, UINT, LCID
  65.             , DISPID *);
  66.         STDMETHODIMP Invoke(DISPID, REFIID, LCID, WORD
  67.             , DISPPARAMS *, VARIANT *, EXCEPINFO *, UINT *);
  68.         //IBeeper functions
  69.         STDMETHODIMP get_Sound(long *);
  70.         STDMETHODIMP put_Sound(long);
  71.         STDMETHODIMP Beep(long *);
  72.     };
  73. typedef CBeeper *PCBeeper;
  74. //DISPIDs for our dispinterface
  75. enum
  76.     {
  77.     PROPERTY_SOUND=0,
  78.     METHOD_BEEP
  79.     };
  80. //Exceptions we can throw from IDispatch::Invoke
  81. enum
  82.     {
  83.     EXCEPTION_NONE=0,
  84.     EXCEPTION_INVALIDSOUND=1000
  85.     };
  86. /*
  87.  * ISupportErrorInfo interface implementations for the Beeper.
  88.  */
  89. class CImpISupportErrorInfo : public ISupportErrorInfo
  90.     {
  91.     public:
  92.         ULONG           m_cRef;     //For debugging
  93.     private:
  94.         PCBeeper        m_pObj;
  95.         LPUNKNOWN       m_pUnkOuter;
  96.     public:
  97.         CImpISupportErrorInfo(PCBeeper, LPUNKNOWN);
  98.         ~CImpISupportErrorInfo(void);
  99.         //IUnknown members that delegate to m_pUnkOuter.
  100.         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
  101.         STDMETHODIMP_(ULONG) AddRef(void);
  102.         STDMETHODIMP_(ULONG) Release(void);
  103.         //ISupportErrorInfo members
  104.         STDMETHODIMP InterfaceSupportsErrorInfo(REFIID);
  105.     };
  106. #endif //_BEEPER_H_