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

Windows编程

开发平台:

Visual C++

  1. /*
  2.  * BEEPER.H
  3.  * Beeper Automation Object #3 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. //Help context ID for exceptions
  27. #define HID_SOUND_PROPERTY_LIMITATIONS  0x1E100
  28. //English exception strings
  29. #define IDS_0_MIN                   16
  30. #define IDS_0_EXCEPTIONSOURCE       (IDS_0_MIN)
  31. #define IDS_0_EXCEPTIONINVALIDSOUND (IDS_0_MIN+1)
  32. //German exception strings
  33. #define IDS_7_MIN                   32
  34. #define IDS_7_EXCEPTIONSOURCE       (IDS_7_MIN)
  35. #define IDS_7_EXCEPTIONINVALIDSOUND (IDS_7_MIN+1)
  36. //Forward class declarations for friend statements
  37. class CImpIDispatch;
  38. typedef CImpIDispatch *PCImpIDispatch;
  39. class CImpISupportErrorInfo;
  40. typedef CImpISupportErrorInfo *PCImpISupportErrorInfo;
  41. class CBeeper : public IBeeper
  42.     {
  43.     friend CImpIDispatch;
  44.     protected:
  45.         ULONG           m_cRef;             //Object reference count
  46.         LPUNKNOWN       m_pUnkOuter;        //Controlling unknown
  47.         PFNDESTROYED    m_pfnDestroy;       //To call on closure
  48.         long            m_lSound;
  49.         //Our interfaces
  50.         PCImpIDispatch         m_pImpIDispatch;
  51.         PCImpISupportErrorInfo m_pImpISuppErr;
  52.     public:
  53.         CBeeper(LPUNKNOWN, PFNDESTROYED);
  54.         ~CBeeper(void);
  55.         BOOL         Init(void);
  56.         //Non-delegating object IUnknown
  57.         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
  58.         STDMETHODIMP_(ULONG) AddRef(void);
  59.         STDMETHODIMP_(ULONG) Release(void);
  60.         //IBeeper functions
  61.         STDMETHODIMP_(long)  get_Sound(void);
  62.         STDMETHODIMP_(void)  put_Sound(long);
  63.         STDMETHODIMP_(long)  Beep(void);
  64.     };
  65. typedef CBeeper *PCBeeper;
  66. //DISPIDs for our dispinterface
  67. enum
  68.     {
  69.     PROPERTY_SOUND=0,
  70.     METHOD_BEEP
  71.     };
  72. /*
  73.  * IDispatch interface implementations for the Beeper.
  74.  */
  75. class CImpIDispatch : public IDispatch
  76.     {
  77.     public:
  78.         ULONG           m_cRef;     //For debugging
  79.     private:
  80.         PCBeeper        m_pObj;
  81.         LPUNKNOWN       m_pUnkOuter;
  82.         ITypeInfo      *m_pITINeutral;      //Type information
  83.         ITypeInfo      *m_pITIGerman;
  84.     public:
  85.         CImpIDispatch(PCBeeper, LPUNKNOWN);
  86.         ~CImpIDispatch(void);
  87.         //For raising exceptions
  88.         void                 Exception(WORD);
  89.         //IUnknown members that delegate to m_pUnkOuter.
  90.         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
  91.         STDMETHODIMP_(ULONG) AddRef(void);
  92.         STDMETHODIMP_(ULONG) Release(void);
  93.         //IDispatch members
  94.         STDMETHODIMP GetTypeInfoCount(UINT *);
  95.         STDMETHODIMP GetTypeInfo(UINT, LCID, ITypeInfo **);
  96.         STDMETHODIMP GetIDsOfNames(REFIID, OLECHAR **, UINT, LCID
  97.             , DISPID *);
  98.         STDMETHODIMP Invoke(DISPID, REFIID, LCID, WORD
  99.             , DISPPARAMS *, VARIANT *, EXCEPINFO *, UINT *);
  100.     };
  101. //Exceptions we can throw from IDispatch::Invoke
  102. enum
  103.     {
  104.     EXCEPTION_NONE=0,
  105.     EXCEPTION_INVALIDSOUND=1000
  106.     };
  107. /*
  108.  * ISupportErrorInfo interface implementations for the Beeper.
  109.  */
  110. class CImpISupportErrorInfo : public ISupportErrorInfo
  111.     {
  112.     public:
  113.         ULONG           m_cRef;     //For debugging
  114.     private:
  115.         PCBeeper        m_pObj;
  116.         LPUNKNOWN       m_pUnkOuter;
  117.     public:
  118.         CImpISupportErrorInfo(PCBeeper, LPUNKNOWN);
  119.         ~CImpISupportErrorInfo(void);
  120.         //IUnknown members that delegate to m_pUnkOuter.
  121.         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
  122.         STDMETHODIMP_(ULONG) AddRef(void);
  123.         STDMETHODIMP_(ULONG) Release(void);
  124.         //ISupportErrorInfo members
  125.         STDMETHODIMP InterfaceSupportsErrorInfo(REFIID);
  126.     };
  127. #endif //_BEEPER_H_