home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Troubleshooting Netware Systems
/
CSTRIAL0196.BIN
/
attach
/
msj
/
v10n05
/
autoole.exe
/
BEEP.EXE
/
BEEPER.H
< prev
next >
Wrap
C/C++ Source or Header
|
1995-05-01
|
5KB
|
217 lines
/*
* BEEPER.H
* Beeper Automation Object
*
* Classes that implement the Beeper object.
*
* Copyright (c)1993-1995 Microsoft Corporation, All Right Reserved
*
* Kraig Brockschmidt, Microsoft
* Internet : kraigb@microsoft.com
* Compuserve: >INTERNET:kraigb@microsoft.com
*/
#ifndef _BEEPER_H_
#define _BEEPER_H_
/*
* This #define tells <bookguid.h> to not define GUIDs that will
* be defined in MKTYPLIB-generated header files, like ibeeper.h.
*/
#define INC_OLE2
#include <windows.h>
#include <ole2.h>
#include <ole2ver.h>
#include <malloc.h>
#ifdef INITGUIDS
#include <initguid.h>
#endif //INITGUIDS
#ifndef WIN32
#include <dispatch.h>
#include <olenls.h>
#else
#include <oleauto.h>
#endif
#ifdef WIN32
#include <tchar.h>
#ifdef UNICODE
#include <wchar.h>
#endif
#endif
//This file is generated from MKTYPLIB
#include "ibeeper.h"
//Help context ID for exceptions
#define HID_SOUND_PROPERTY_LIMITATIONS 0x1E100
//English exception strings
#define IDS_0_MIN 16
#define IDS_0_EXCEPTIONSOURCE (IDS_0_MIN)
#define IDS_0_EXCEPTIONINVALIDSOUND (IDS_0_MIN+1)
//German exception strings
#define IDS_7_MIN 32
#define IDS_7_EXCEPTIONSOURCE (IDS_7_MIN)
#define IDS_7_EXCEPTIONINVALIDSOUND (IDS_7_MIN+1)
#ifndef PPVOID
typedef LPVOID * PPVOID;
#endif //PPVOID
//Type for an object-destroyed callback
typedef void (*PFNDESTROYED)(void);
//Macros for setting EXCEPINFO structures
#define SETEXCEPINFO(ei, excode, src, desc, file, ctx, func, scd) \
{\
(ei).wCode=excode;\
(ei).wReserved=0;\
(ei).bstrSource=src;\
(ei).bstrDescription=desc;\
(ei).bstrHelpFile=file;\
(ei).dwHelpContext=ctx;\
(ei).pvReserved=NULL;\
(ei).pfnDeferredFillIn=func;\
(ei).scode=scd;\
}
#define INITEXCEPINFO(ei) \
SETEXCEPINFO(ei,0,NULL,NULL,NULL,0L,NULL,S_OK)
//DeleteInterfaceImp calls 'delete' and NULLs the pointer
#define DeleteInterfaceImp(p)\
{\
if (NULL!=p)\
{\
delete p;\
p=NULL;\
}\
}
//ReleaseInterface calls 'Release' and NULLs the pointer
#define ReleaseInterface(p)\
{\
if (NULL!=p)\
{\
p->Release();\
p=NULL;\
}\
}
//Forward class declarations for friend statements
class CImpIDispatch;
typedef CImpIDispatch *PCImpIDispatch;
class CBeeper : public IBeeper
{
friend CImpIDispatch;
protected:
ULONG m_cRef; //Object reference count
LPUNKNOWN m_pUnkOuter; //Controlling unknown
PFNDESTROYED m_pfnDestroy; //To call on closure
long m_lSound;
PCImpIDispatch m_pImpIDispatch; //Our IDispatch
public:
CBeeper(LPUNKNOWN, PFNDESTROYED);
~CBeeper(void);
BOOL Init(void);
//Non-delegating object IUnknown
STDMETHODIMP QueryInterface(REFIID, PPVOID);
STDMETHODIMP_(ULONG) AddRef(void);
STDMETHODIMP_(ULONG) Release(void);
//IBeeper functions
STDMETHODIMP_(long) get_Sound(void);
STDMETHODIMP_(void) put_Sound(long);
STDMETHODIMP_(long) Beep(void);
};
typedef CBeeper *PCBeeper;
//DISPIDs for our dispinterface
enum
{
PROPERTY_SOUND=0,
METHOD_BEEP
};
/*
* IDispatch interface implementations for the Beeper.
*/
class CImpIDispatch : public IDispatch
{
public:
ULONG m_cRef; //For debugging
private:
PCBeeper m_pObj;
LPUNKNOWN m_pUnkOuter;
WORD m_wException;
ITypeInfo *m_pITINeutral; //Type information
ITypeInfo *m_pITIGerman;
public:
CImpIDispatch(PCBeeper, LPUNKNOWN);
~CImpIDispatch(void);
/*
* This function is called from CBeeper functions that
* are called from within DispInvoke to set an exception.
* This is because the CBeeper functions have no way to
* tell DispInvoke of such exceptions, so we have to
* tell our IDispatch::Invoke implementation directly.
*/
void Exception(WORD);
//IUnknown members that delegate to m_pUnkOuter.
STDMETHODIMP QueryInterface(REFIID, PPVOID);
STDMETHODIMP_(ULONG) AddRef(void);
STDMETHODIMP_(ULONG) Release(void);
//IDispatch members
STDMETHODIMP GetTypeInfoCount(UINT *);
STDMETHODIMP GetTypeInfo(UINT, LCID, ITypeInfo **);
STDMETHODIMP GetIDsOfNames(REFIID, TCHAR **, UINT, LCID
, DISPID *);
STDMETHODIMP Invoke(DISPID, REFIID, LCID, WORD
, DISPPARAMS *, VARIANT *, EXCEPINFO *, UINT *);
};
//Exceptions we can throw from IDispatch::Invoke
enum
{
EXCEPTION_NONE=0,
EXCEPTION_INVALIDSOUND=1000
};
//Exception filling function for the EXCEPINFO structure.
HRESULT STDAPICALLTYPE FillException(EXCEPINFO *);
#endif //_BEEPER_H_