home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / com / inole2 / interfac / imarshal.cpp < prev    next >
C/C++ Source or Header  |  1996-05-21  |  5KB  |  217 lines

  1. /*
  2.  * IMARSHAL.CPP
  3.  *
  4.  * Template IMarshal interface implementation.
  5.  *
  6.  * Copyright (c)1993-1995 Microsoft Corporation, All Rights Reserved
  7.  *
  8.  * Kraig Brockschmidt, Microsoft
  9.  * Internet  :  kraigb@microsoft.com
  10.  * Compuserve:  >INTERNET:kraigb@microsoft.com
  11.  */
  12.  
  13.  
  14. #include "imarshal.h"
  15.  
  16.  
  17. /*
  18.  * CImpIMarshal::CImpIMarshal
  19.  * CImpIMarshal::~CImpIMarshal
  20.  *
  21.  * Parameters (Constructor):
  22.  *  pObj            LPVOID of the object we're in.
  23.  *  pUnkOuter       LPUNKNOWN to which we delegate.
  24.  */
  25.  
  26. CImpIMarshal::CImpIMarshal(LPVOID pObj, LPUNKNOWN pUnkOuter)
  27.     {
  28.     m_cRef=0;
  29.     m_pObj=pObj;
  30.     m_pUnkOuter=pUnkOuter;
  31.     return;
  32.     }
  33.  
  34. CImpIMarshal::~CImpIMarshal(void)
  35.     {
  36.     return;
  37.     }
  38.  
  39.  
  40.  
  41. /*
  42.  * CImpIMarshal::QueryInterface
  43.  * CImpIMarshal::AddRef
  44.  * CImpIMarshal::Release
  45.  *
  46.  * Purpose:
  47.  *  Delegating IUnknown members for CImpIMarshal.
  48.  */
  49.  
  50. STDMETHODIMP CImpIMarshal::QueryInterface(REFIID riid
  51.     , LPVOID *ppv)
  52.     {
  53.     return m_pUnkOuter->QueryInterface(riid, ppv);
  54.     }
  55.  
  56. STDMETHODIMP_(ULONG) CImpIMarshal::AddRef(void)
  57.     {
  58.     ++m_cRef;
  59.     return m_pUnkOuter->AddRef();
  60.     }
  61.  
  62. STDMETHODIMP_(ULONG) CImpIMarshal::Release(void)
  63.     {
  64.     --m_cRef;
  65.     return m_pUnkOuter->Release();
  66.     }
  67.  
  68.  
  69.  
  70.  
  71.  
  72. /*
  73.  * CImpIMarshal::GetUnmarshalClass
  74.  *
  75.  * Purpose:
  76.  *  Determines the class of object to be used to create an
  77.  *  uninitalized proxy in the unmarshaling process.
  78.  *
  79.  * Parameters:
  80.  *  riid            REFIID of the interface to be marshaled.
  81.  *  pv              LPVOID to the interface to be marshaled.
  82.  *  dwCtx           DWORD specifying the relation of the processes
  83.  *                  between which the marshaling is occuring, from the
  84.  *                  MSHCTX enumeration.
  85.  *  pvCtx           LPVOID Reserved for future MSHCTX values.
  86.  *  dwFlags         DWORD specifying why marshaling is taking place.
  87.  *  pClsID          LPCLSID in which to store the proxy CLSID.
  88.  */
  89.  
  90. STDMETHODIMP CImpIMarshal::GetUnmarshalClass(REFIID riid
  91.     , LPVOID pv, DWORD dwCtx, LPVOID pvCtx, DWORD dwFlags
  92.     , LPCLSID pClsID)
  93.     {
  94.     return ResultFromScode(E_NOTIMPL);
  95.     }
  96.  
  97.  
  98.  
  99.  
  100. /*
  101.  * CImpIMarshal::GetMarshalSizeMax
  102.  *
  103.  * Purpose:
  104.  *  Returns the upper memory bound needed to write data into a stream
  105.  *  for IMarshal::MarshalInterface.
  106.  *
  107.  * Parameters:
  108.  *  riid            REFIID of the interface to be marshaled.
  109.  *  pv              LPVOID of the interface to be marshaled.
  110.  *  dwDestCtx       DWORD with the destination context from MSHCTX.
  111.  *  pvDestCtx       LPVOID reserved for future MSHCTX flags.
  112.  *  dwFlags         DWORD specifying why marshaling is taking place.
  113.  *  pdwSize         LPDWORD in which the size is returned.
  114.  */
  115.  
  116. STDMETHODIMP CImpIMarshal::GetMarshalSizeMax(REFIID riid, LPVOID pv
  117.     , DWORD dwDestCtx, LPVOID pvDestCtx, DWORD dwFlags
  118.     , LPDWORD pdwSize)
  119.     {
  120.     return ResultFromScode(E_NOTIMPL);
  121.     }
  122.  
  123.  
  124.  
  125.  
  126.  
  127. /*
  128.  * CImpIMarshal::MarshalInterface
  129.  *
  130.  * Purpose:
  131.  *  Stores a marshaling packet in a stream for use by a client-side
  132.  *  proxy.
  133.  *
  134.  * Parameters:
  135.  *  pStm            LPSTREAM into which to marshal the interface.
  136.  *  riid            REFIID of the interface to be marshaled.
  137.  *  pv              LPVOID of the interface to be marshaled.
  138.  *  dwDestCtx       DWORD with the destination context from MSHCTX.
  139.  *  pvDestCtx       LPVOID reserved for future MSHCTX flags.
  140.  *  dwFlags         DWORD specifying why marshaling is taking place.
  141.  */
  142.  
  143. STDMETHODIMP CImpIMarshal::MarshalInterface(LPSTREAM pstm
  144.     , REFIID riid, LPVOID pv, DWORD dwDestCtx, LPVOID pvDestCtx
  145.     , DWORD dwFlags)
  146.     {
  147.     return ResultFromScode(E_NOTIMPL);
  148.     }
  149.  
  150.  
  151.  
  152.  
  153.  
  154. /*
  155.  * CImpIMarshal::UnmarshalInterface
  156.  *
  157.  * Purpose:
  158.  *  Initializes a newly created proxy the marshaling packet in
  159.  *  the stream created in the server-side implementation of
  160.  *  MarshalInterface.  This is the primary member of this interface
  161.  *  used on the client side proxy.
  162.  *
  163.  * Parameters:
  164.  *  pStm            LPSTREAM to the stream containing marshal
  165.  *                  data.
  166.  *  riid            REFIID of the interface to be marshaled.
  167.  *  ppv             LPVOID * in which to return the pointer for the
  168.  *                  client.
  169.  */
  170.  
  171. STDMETHODIMP CImpIMarshal::UnmarshalInterface(LPSTREAM pstm
  172.     , REFIID riid, LPVOID *ppv)
  173.     {
  174.     return ResultFromScode(E_NOTIMPL);
  175.     }
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182. /*
  183.  * CImpIMarshal::ReleaseMarshalData
  184.  *
  185.  * Purpose:
  186.  *  Destroy a marshaled data packet.
  187.  *
  188.  * Parameters:
  189.  *  pStm            LPSTREAM containing the data to release.
  190.  */
  191.  
  192. STDMETHODIMP CImpIMarshal::ReleaseMarshalData(LPSTREAM pstm)
  193.     {
  194.     return ResultFromScode(E_NOTIMPL);
  195.     }
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. /*
  203.  * CImpIMarshal::Disconnect
  204.  *
  205.  * Purpose:
  206.  *  Instructs an object with custom marshaling that it's being
  207.  *  disconnected.
  208.  *
  209.  * Parameters:
  210.  *  dwReserved      DWORD reserved.
  211.  */
  212.  
  213. STDMETHODIMP CImpIMarshal::DisconnectObject(DWORD dwReserved)
  214.     {
  215.     return ResultFromScode(E_NOTIMPL);
  216.     }
  217.