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 / iperfile.cpp < prev    next >
C/C++ Source or Header  |  1995-05-03  |  4KB  |  203 lines

  1. /*
  2.  * IPERFILE.CPP
  3.  *
  4.  * Template IPersistFile 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 "iperfile.h"
  15.  
  16.  
  17. /*
  18.  * CImpIPersistFile:CImpIPersistFile
  19.  * CImpIPersistFile::~CImpIPersistFile
  20.  *
  21.  * Constructor Parameters:
  22.  *  pObj            LPVOID pointing to the object we live in.
  23.  *  pUnkOuter       LPUNKNOWN of the controlling unknown.
  24.  */
  25.  
  26. CImpIPersistFile::CImpIPersistFile(LPVOID pObj, LPUNKNOWN pUnkOuter)
  27.     {
  28.     m_cRef=0;
  29.     m_pObj=pObj;
  30.     m_pUnkOuter=pUnkOuter;
  31.     return;
  32.     }
  33.  
  34.  
  35. CImpIPersistFile::~CImpIPersistFile(void)
  36.     {
  37.     return;
  38.     }
  39.  
  40.  
  41.  
  42. /*
  43.  * CImpIPersistFile::QueryInterface
  44.  * CImpIPersistFile::AddRef
  45.  * CImpIPersistFile::Release
  46.  *
  47.  * Purpose:
  48.  *  Delegating IUnknown members for CImpIPersistFile.
  49.  */
  50.  
  51. STDMETHODIMP CImpIPersistFile::QueryInterface(REFIID riid
  52.     , LPVOID *ppv)
  53.     {
  54.     return m_pUnkOuter->QueryInterface(riid, ppv);
  55.     }
  56.  
  57. STDMETHODIMP_(ULONG) CImpIPersistFile::AddRef(void)
  58.     {
  59.     ++m_cRef;
  60.     return m_pUnkOuter->AddRef();
  61.     }
  62.  
  63. STDMETHODIMP_(ULONG) CImpIPersistFile::Release(void)
  64.     {
  65.     --m_cRef;
  66.     return m_pUnkOuter->Release();
  67.     }
  68.  
  69.  
  70.  
  71.  
  72.  
  73. /*
  74.  * CImpIPersistFile::GetClassID
  75.  *
  76.  * Purpose:
  77.  *  Returns the CLSID of the file represented by this interface.
  78.  *
  79.  * Parameters:
  80.  *  pClsID          LPCLSID in which to store our CLSID.
  81.  */
  82.  
  83. STDMETHODIMP CImpIPersistFile::GetClassID(LPCLSID pClsID)
  84.     {
  85.     return NOERROR;
  86.     }
  87.  
  88.  
  89.  
  90.  
  91.  
  92. /*
  93.  * CImpIPersistFile::IsDirty
  94.  *
  95.  * Purpose:
  96.  *  Tells the caller if we have made changes to this object since
  97.  *  it was loaded or initialized new.
  98.  *
  99.  * Parameters:
  100.  *  None
  101.  *
  102.  * Return Value:
  103.  *  HRESULT         Contains S_OK if we ARE dirty, S_FALSE if
  104.  *                  NOT dirty.
  105.  */
  106.  
  107. STDMETHODIMP CImpIPersistFile::IsDirty(void)
  108.     {
  109.     return ResultFromScode(S_FALSE);
  110.     }
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119. /*
  120.  * CImpIPersistFile::Load
  121.  *
  122.  * Purpose:
  123.  *  Asks the server to load the document for the given filename.
  124.  *
  125.  * Parameters:
  126.  *  pszFile         LPCOLESTR of the filename to load.
  127.  *  grfMode         DWORD flags to use when opening the file.
  128.  */
  129.  
  130. STDMETHODIMP CImpIPersistFile::Load(LPCOLESTR pszFile, DWORD grfMode)
  131.     {
  132.     return ResultFromScode(E_NOTIMPL);
  133.     }
  134.  
  135.  
  136.  
  137.  
  138.  
  139. /*
  140.  * CImpIPersistFile::Save
  141.  *
  142.  * Purpose:
  143.  *  Instructs the server to write the current file into a new
  144.  *  filename, possibly then using that filename as the current one.
  145.  *
  146.  * Parameters:
  147.  *  pszFile         LPCOLESTR of the file into which we save.  If NULL,
  148.  *                  this means save the current file.
  149.  *  fRemember       BOOL indicating if we're to use this filename as
  150.  *                  the current file now (Save As instead of Save
  151.  *                  Copy As).
  152.  */
  153.  
  154. STDMETHODIMP CImpIPersistFile::Save(LPCOLESTR pszFile, BOOL fRemember)
  155.     {
  156.     return ResultFromScode(E_NOTIMPL);
  157.     }
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166. /*
  167.  * CImpIPersistFile::SaveCompleted
  168.  *
  169.  * Purpose:
  170.  *  Informs us that the operation that called Save is now finished
  171.  *  and we can access the file again.
  172.  *
  173.  * Parameters:
  174.  *  pszFile         LPCOLESTR of the file in which we can start
  175.  *                  writing again.
  176.  */
  177.  
  178. STDMETHODIMP CImpIPersistFile::SaveCompleted(LPCOLESTR pszFile)
  179.     {
  180.     return NOERROR;
  181.     }
  182.  
  183.  
  184.  
  185.  
  186.  
  187. /*
  188.  * CImpIPersistFile::GetCurFile
  189.  *
  190.  * Purpose:
  191.  *  Returns the current filename.
  192.  *
  193.  * Parameters:
  194.  *  ppszFile        LPOLESTR * into which we store a pointer to
  195.  *                  the filename that should be allocated with the
  196.  *                  shared IMalloc.
  197.  */
  198.  
  199. STDMETHODIMP CImpIPersistFile::GetCurFile(LPOLESTR *ppszFile)
  200.     {
  201.     return ResultFromScode(E_NOTIMPL);
  202.     }
  203.