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

Windows编程

开发平台:

Visual C++

  1. /**************************************************************************
  2.  *
  3.  *  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  4.  *  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  5.  *  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
  6.  *  PURPOSE.
  7.  *
  8.  *  Copyright (C) 1992 - 1997 Microsoft Corporation.  All Rights Reserved.
  9.  *
  10.  **************************************************************************/
  11. extern HMODULE ghModule; // = NULL; // global HMODULE/HINSTANCE for resource access
  12. // Comment out the following line to disable the custom marshalling code....
  13. #define CUSTOMMARSHAL
  14. /*      -       -       -       -       -       -       -       -       */
  15. #define CFactoryImpl    CI      // MSC7 Can't handle long exported names
  16. #define CAVIFileImpl    CF      // MSC7 Can't handle long exported names
  17. #define CAVIStreamImpl  CS      // MSC7 Can't handle long exported names
  18. /* Remove warning of using object during initialization. */
  19. #pragma warning(disable:4355)
  20. /*      -       -       -       -       -       -       -       -       */
  21. #define implement       struct
  22. #define implementations private
  23. /*
  24. ** _StdClassImplementations
  25. ** Defines the standard implementations for a class object.
  26. */
  27. #define _StdClassImplementations(Impl)  
  28.         STDMETHODIMP QueryInterface(const IID FAR& riid, void FAR* FAR* ppv);   
  29.         STDMETHODIMP_(ULONG) AddRef();  
  30.         STDMETHODIMP_(ULONG) Release()
  31. // non-member function prototypes
  32. EXTERN_C BOOL PASCAL FAR LibMain(
  33.         HINSTANCE       hInstance,
  34.         HGLOBAL segDS,
  35.         UINT    cbHeapSize,
  36.         LPCSTR  pszCmdLine);
  37. EXTERN_C BOOL FAR PASCAL WEP(
  38.         BOOL    fSystemExit);
  39. STDAPI DllCanUnloadNow(
  40.         void);
  41. STDAPI DllGetClassObject(
  42.         const CLSID FAR&        rclsid,
  43.         const IID FAR&  riid,
  44.         void FAR* FAR*  ppv);
  45. LPSTR FAR FileName(
  46.         LPCSTR lszPath);
  47. /*      -       -       -       -       -       -       -       -       */
  48. class FAR CAVIFileCF : IClassFactory {
  49. public:
  50.         static HRESULT Create(const CLSID FAR& rclsid, const IID FAR& riid, void FAR* FAR* ppv);
  51. private:
  52.         CAVIFileCF(const CLSID FAR& rclsid, IUnknown FAR* FAR* ppUnknown);
  53.         _StdClassImplementations(CFactoryImpl);
  54.         CFactoryImpl(CAVIFileCF FAR* pAVIFileCF);
  55.         STDMETHODIMP CreateInstance(IUnknown FAR* pUnknownOuter, const IID FAR& riid, void FAR* FAR* ppv);
  56.         STDMETHODIMP LockServer(BOOL fLock);
  57.         ULONG   m_refs;
  58.         CLSID   m_clsid;
  59. };
  60. /*      -       -       -       -       -       -       -       -       */
  61. class FAR CAVIFile {
  62. public:
  63.         static HRESULT Create(IUnknown FAR* pUnknownOuter, const IID FAR& riid, void FAR* FAR* ppv);
  64.         HRESULT NEAR PASCAL LoadFrame(LONG lPos);
  65.         HRESULT NEAR PASCAL WriteFrame(LONG lPos, LPVOID lp, LONG cb);
  66. private:
  67.         CAVIFile(IUnknown FAR* pUnknownOuter, IUnknown FAR* FAR* ppUnknown);
  68. implementations:
  69.         implement CUnknownImpl : IUnknown {
  70.         public:
  71.                 _StdClassImplementations(
  72.                         CUnknownImpl);
  73.                 CUnknownImpl(
  74.                         CAVIFile FAR* pAVIFile);
  75.         private:
  76.                 CAVIFile FAR*   m_pAVIFile;
  77.                 ULONG   m_refs;
  78.         };
  79.         implement CAVIFileImpl : IAVIFile {
  80.         public:
  81.                 _StdClassImplementations(
  82.                         CAVIFileImpl);
  83.                 CAVIFileImpl(
  84.                         CAVIFile FAR* pAVIFile);
  85.                 ~CAVIFileImpl();
  86.                 STDMETHODIMP Info(
  87.                         THIS_
  88.                         AVIFILEINFOW * pfi,
  89.                         LONG lSize);
  90.                 STDMETHODIMP GetStream(
  91.                         THIS_
  92.                         PAVISTREAM FAR * ppStream,
  93.                         DWORD fccType,
  94.                         LONG lParam);
  95.                 STDMETHODIMP CreateStream(
  96.                         THIS_
  97.                         PAVISTREAM FAR * ppStream,
  98.                         AVISTREAMINFOW * psi);
  99.                 STDMETHODIMP WriteData(
  100.                         THIS_
  101.                         DWORD ckid,
  102.                         LPVOID lpData,
  103.                         LONG cbData);
  104.                 STDMETHODIMP ReadData(
  105.                         THIS_
  106.                         DWORD ckid,
  107.                         LPVOID lpData,
  108.                         LONG FAR *lpcbData);
  109.                 STDMETHODIMP EndRecord(
  110.                         THIS);
  111.                 STDMETHODIMP DeleteStream(THIS_
  112.                                             DWORD fccType,
  113.                                             LONG lParam);
  114.         private:
  115.                 // private functions here?
  116.                 CAVIFile FAR*   m_pAVIFile;
  117.         };
  118.         implement CAVIStreamImpl : IAVIStream {
  119.         public:
  120.                 _StdClassImplementations(
  121.                         CAVIStreamImpl);
  122.                 CAVIStreamImpl(
  123.                         CAVIFile FAR* pAVIFile);
  124.                 ~CAVIStreamImpl();
  125.                 STDMETHODIMP Create(
  126.                         THIS_
  127.                         LPARAM lParam1,
  128.                         LPARAM lParam2);
  129.                 STDMETHODIMP Info(
  130.                         THIS_
  131.                         AVISTREAMINFOW FAR * psi,
  132.                         LONG lSize);
  133.                 STDMETHODIMP_(LONG) FindSample(
  134.                         THIS_
  135.                         LONG lPos,
  136.                         LONG lFlags);
  137.                 STDMETHODIMP ReadFormat(
  138.                         THIS_
  139.                         LONG lPos,
  140.                         LPVOID lpFormat,
  141.                         LONG FAR *cbFormat);
  142.                 STDMETHODIMP SetFormat(
  143.                         THIS_
  144.                         LONG lPos,
  145.                         LPVOID lpFormat,
  146.                         LONG cbFormat);
  147.                 STDMETHODIMP Read(
  148.                         THIS_
  149.                         LONG lStart,
  150.                         LONG lSamples,
  151.                         LPVOID lpBuffer,
  152.                         LONG cbBuffer,
  153.                         LONG FAR * plBytes,
  154.                         LONG FAR * plSamples);
  155.                 STDMETHODIMP Write(
  156.                         THIS_
  157.                         LONG lStart,
  158.                         LONG lSamples,
  159.                         LPVOID lpBuffer,
  160.                         LONG cbBuffer,
  161.                         DWORD dwFlags,
  162.                         LONG FAR *plSampWritten,
  163.                         LONG FAR *plBytesWritten);
  164.                 STDMETHODIMP Delete(
  165.                         THIS_
  166.                         LONG lStart,
  167.                         LONG lSamples);
  168.                 STDMETHODIMP ReadData(
  169.                         THIS_
  170.                         DWORD fcc,
  171.                         LPVOID lp,
  172.                         LONG FAR *lpcb);
  173.                 STDMETHODIMP WriteData(
  174.                         THIS_
  175.                         DWORD fcc,
  176.                         LPVOID lp,
  177.                         LONG cb);
  178.                 STDMETHODIMP SetInfo(AVISTREAMINFOW FAR * lpInfo, LONG cbInfo);
  179.         private:
  180.                 // private functions here?
  181.                 CAVIFile FAR*   m_pAVIFile;
  182.         };
  183.         implement CPersistFileImpl : IPersistFile {
  184.         public:
  185.             CPersistFileImpl(CAVIFile FAR* pAVIFile);
  186.             STDMETHODIMP QueryInterface(REFIID riid, LPVOID FAR* ppv);
  187.             STDMETHODIMP_(ULONG) AddRef();
  188.             STDMETHODIMP_(ULONG) Release();
  189.             // *** IPersist methods ***
  190.             STDMETHODIMP GetClassID (LPCLSID lpClassID);
  191.             // *** IPersistFile methods ***
  192.             STDMETHODIMP IsDirty ();
  193.             STDMETHODIMP Load (LPCOLESTR lpszFileName, DWORD grfMode);
  194.             STDMETHODIMP Save (LPCOLESTR lpszFileName, BOOL fRemember);
  195.             STDMETHODIMP SaveCompleted (LPCOLESTR lpszFileName);
  196.             STDMETHODIMP GetCurFile (LPOLESTR FAR * lplpszFileName);
  197.         private:
  198.             CAVIFile FAR*       m_pAVIFile;
  199.         };
  200. #ifdef CUSTOMMARSHAL
  201.         implement CMarshalImpl : IMarshal {
  202.         public:
  203.                 _StdClassImplementations(
  204.                         CMarshalImpl);
  205.                 CMarshalImpl(
  206.                         CAVIFile FAR* pAVIFile);
  207.                 // *** IMarshal methods ***
  208.                 STDMETHODIMP GetUnmarshalClass (
  209.                         THIS_
  210.                         REFIID riid,
  211.                         LPVOID pv,
  212.                         DWORD dwDestContext,
  213.                         LPVOID pvDestContext,
  214.                         DWORD mshlflags,
  215.                         LPCLSID pCid);
  216.                 STDMETHODIMP GetMarshalSizeMax (
  217.                         THIS_
  218.                         REFIID riid,
  219.                         LPVOID pv,
  220.                         DWORD dwDestContext,
  221.                         LPVOID pvDestContext,
  222.                         DWORD mshlflags,
  223.                         LPDWORD pSize);
  224.                 STDMETHODIMP MarshalInterface(
  225.                         THIS_
  226.                         LPSTREAM pStm,
  227.                         REFIID riid,
  228.                         LPVOID pv,
  229.                         DWORD dwDestContext,
  230.                         LPVOID pvDestContext,
  231.                         DWORD mshlflags);
  232.                 STDMETHODIMP UnmarshalInterface (
  233.                         THIS_
  234.                         LPSTREAM pStm,
  235.                         REFIID riid,
  236.                         LPVOID FAR* ppv);
  237.                 STDMETHODIMP ReleaseMarshalData (
  238.                         THIS_
  239.                         LPSTREAM pStm);
  240.                 STDMETHODIMP DisconnectObject (
  241.                 THIS_
  242.                 DWORD dwReserved);
  243.         private:
  244.                 CAVIFile FAR*   m_pAVIFile;
  245.         };
  246. #endif
  247. public:
  248.         CUnknownImpl    m_Unknown;
  249.         CAVIFileImpl    m_AVIFile;
  250.         CAVIStreamImpl  m_AVIStream;
  251.         CPersistFileImpl m_Persist;
  252. #ifdef CUSTOMMARSHAL
  253.         CMarshalImpl    m_Marshal;
  254. #endif
  255. public:
  256.         IUnknown FAR*   m_pUnknownOuter;
  257.         //
  258.         // DIB Sequence instance data
  259.         //
  260.         DWORD   dwFirstFrame;
  261.         DWORD   dwMaxValue;
  262. #ifndef _MAX_PATH
  263.         #define _MAX_PATH       260
  264. #else
  265.         #if _MAX_PATH !=        260     // Error check
  266.                 #error
  267.         #endif
  268. #endif
  269.         char    achFilenameTemplate[_MAX_PATH];
  270.         LONG    lCurFrame;
  271.         AVIFILEINFO     finfo;
  272.         AVISTREAMINFOW sinfo;
  273.         BOOL    fStreamPresent;
  274.         LPVOID  lpFormat;       // stream format
  275.         LONG    cbFormat;
  276.         LONG    cbFormatBuffer;
  277.         LPVOID  lpFrame;
  278.         LONG    cbFrame;
  279.         LONG    cbFrameBuffer;
  280.         BOOL    fDirty;
  281.         UINT    mode;
  282. };
  283. /*      -       -       -       -       -       -       -       -       */
  284. /*
  285. ** The usage counter keeps track of the overall usage of objects based on
  286. ** implementations provided by the component. This allows one to determine
  287. ** when the implementation is no longer in use.
  288. */
  289. extern UINT     uUseCount;
  290. extern BOOL     fLocked;
  291. /*      -       -       -       -       -       -       -       -       */
  292. DEFINE_AVIGUID(CLSID_DIBSEQFileReader, 0x00020006, 0, 0);