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 / imoniker.cpp < prev    next >
C/C++ Source or Header  |  1996-05-21  |  12KB  |  550 lines

  1. /*
  2.  * IMONIKER.CPP
  3.  *
  4.  * Template IMoniker 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 "imoniker.h"
  15.  
  16.  
  17. /*
  18.  * CImpIMoniker::CImpIMoniker
  19.  * CImpIMoniker::~CImpIMoniker
  20.  *
  21.  * Parameters (Constructor):
  22.  *  pObj            LPVOID of the object we're in.
  23.  *  pUnkOuter       LPUNKNOWN to which we delegate.
  24.  */
  25.  
  26. CImpIMoniker::CImpIMoniker(LPVOID pObj, LPUNKNOWN pUnkOuter)
  27.     {
  28.     m_cRef=0;
  29.     m_pObj=pObj;
  30.     m_pUnkOuter=pUnkOuter;
  31.     return;
  32.     }
  33.  
  34. CImpIMoniker::~CImpIMoniker(void)
  35.     {
  36.     return;
  37.     }
  38.  
  39.  
  40.  
  41. /*
  42.  * CImpIMoniker::QueryInterface
  43.  * CImpIMoniker::AddRef
  44.  * CImpIMoniker::Release
  45.  *
  46.  * Purpose:
  47.  *  Delegating IUnknown members for CImpIMoniker.
  48.  */
  49.  
  50. STDMETHODIMP CImpIMoniker::QueryInterface(REFIID riid
  51.     , LPVOID *ppv)
  52.     {
  53.     return m_pUnkOuter->QueryInterface(riid, ppv);
  54.     }
  55.  
  56. STDMETHODIMP_(ULONG) CImpIMoniker::AddRef(void)
  57.     {
  58.     ++m_cRef;
  59.     return m_pUnkOuter->AddRef();
  60.     }
  61.  
  62. STDMETHODIMP_(ULONG) CImpIMoniker::Release(void)
  63.     {
  64.     --m_cRef;
  65.     return m_pUnkOuter->Release();
  66.     }
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74. /*
  75.  * CImpIMoniker::GetClassID
  76.  *
  77.  * Purpose:
  78.  *  Return the CLSID of the moniker.
  79.  *
  80.  * Parameters:
  81.  *  pClsID          LPCLSID in which to store the CLSID.
  82.  */
  83.  
  84. STDMETHODIMP CImpIMoniker::GetClassID(LPCLSID pClsID)
  85.     {
  86.     return ResultFromScode(E_NOTIMPL);
  87.     }
  88.  
  89.  
  90.  
  91.  
  92.  
  93. /*
  94.  * CImpIMoniker::IsDirty
  95.  *
  96.  * Purpose:
  97.  *  Answers whether the state of the moniker itself is dirty.
  98.  *
  99.  * Parameters:
  100.  *  None
  101.  *
  102.  * Return Value:
  103.  *  HRESULT         S_TRUE if the moniker is dirty, S_FALSE if not.
  104.  *                  Possibly a failure code.
  105.  */
  106.  
  107. STDMETHODIMP CImpIMoniker::IsDirty(void)
  108.     {
  109.     return ResultFromScode(E_NOTIMPL);
  110.     }
  111.  
  112.  
  113.  
  114.  
  115.  
  116. /*
  117.  * CImpIMoniker::Load
  118.  *
  119.  * Purpose:
  120.  *  Initializes the moniker from the information in a stream.
  121.  *
  122.  * Parameters:
  123.  *  pstm            LPSTREAM containing the moniker's information.
  124.  */
  125.  
  126. STDMETHODIMP CImpIMoniker::Load(LPSTREAM pstm)
  127.     {
  128.     return ResultFromScode(E_NOTIMPL);
  129.     }
  130.  
  131.  
  132.  
  133.  
  134.  
  135. /*
  136.  * CImpIMoniker::Save
  137.  *
  138.  * Purpose:
  139.  *  Instructs the moniker to save its state to a stream.
  140.  *
  141.  * Parameters:
  142.  *  pstm            LPSTREAM in which to save the moniker.
  143.  *  fClearDirty     BOOL indicating if the object is to clear its
  144.  *                  dirty flag after the save.
  145.  */
  146.  
  147. STDMETHODIMP CImpIMoniker::Save(LPSTREAM pstm, BOOL fClearDirty)
  148.     {
  149.     return ResultFromScode(E_NOTIMPL);
  150.     }
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157. /*
  158.  * CImpIMoniker::GetSizeMax
  159.  *
  160.  * Purpose:
  161.  *  Returns the size of a stream the moniker need to store its
  162.  *  persistent state.
  163.  *
  164.  * Parameters:
  165.  *  pcbSize         ULARGE_INTEGER * in which to store the size.
  166.  */
  167.  
  168. STDMETHODIMP CImpIMoniker::GetSizeMax(ULARGE_INTEGER *pcbSize)
  169.     {
  170.     return ResultFromScode(E_NOTIMPL);
  171.     }
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178. /*
  179.  * CImpIMoniker::BindToObject
  180.  *
  181.  * Purpose:
  182.  *  Instructs a moniker to locate and load the object it refereces.
  183.  *
  184.  * Parameters:
  185.  *  pBindCtx        LPBC to the bind context.
  186.  *  pmkLeft         LPMONIKER to the "left" of this moniker.
  187.  *  riid            REFIID of the interface desired on the object
  188.  *  ppvObj          LPVOID * into which to store the bound object's
  189.  *                  interface pointer.
  190.  */
  191.  
  192. STDMETHODIMP CImpIMoniker::BindToObject(LPBC pBindCtx
  193.     , LPMONIKER pmkLeft, REFIID riid, LPVOID *ppvObj)
  194.     {
  195.     return ResultFromScode(E_NOTIMPL);
  196.     }
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203. /*
  204.  * CImpIMoniker::BindToStorage
  205.  *
  206.  * Purpose:
  207.  *  Locates and returns an interface pointer to the storage of
  208.  *  the object referenced by this moniker.
  209.  *
  210.  * Parameters:
  211.  *  pBindCtx        LPBC to the bind context.
  212.  *  pmkLeft         LPMONIKER to the "left" of this moniker.
  213.  *  riid            REFIID of the interface desired on the object
  214.  *  ppvObj          LPVOID * into which to store the bound object's
  215.  *                  interface pointer.
  216.  */
  217.  
  218. STDMETHODIMP CImpIMoniker::BindToStorage(LPBC pBindCtx
  219.     , LPMONIKER pmkLeft, REFIID riid, LPVOID *ppvObj)
  220.     {
  221.     return ResultFromScode(E_NOTIMPL);
  222.     }
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229. /*
  230.  * CImpIMoniker::Reduce
  231.  *
  232.  * Purpose:
  233.  *  Returns a more or equally efficient moniker equivalent to
  234.  *  this moniker.
  235.  *
  236.  * Parameters:
  237.  *  pBindCtx        LPBC to the bind context.
  238.  *  dwHowFar        DWORD indicating how far the reduction should go.
  239.  *  ppmkLeft        LPMONIKER * (in-out) contains initial left moniker
  240.  *                  on input and a new prefix on output (if necessary).
  241.  *  ppmkReduced     LPMONIKER * into which to store the reduced moniker.
  242.  */
  243.  
  244. STDMETHODIMP CImpIMoniker::Reduce(LPBC pBindCtx, DWORD dwHowFar
  245.     , LPMONIKER *ppmkLeft, LPMONIKER *ppmkReduced)
  246.     {
  247.     return ResultFromScode(E_NOTIMPL);
  248.     }
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255. /*
  256.  * CImpIMoniker::ComposeWith
  257.  *
  258.  * Purpose:
  259.  *  Returns a new composite moniker composed with this moniker on
  260.  *  the left and ppmkRight on the right.
  261.  *
  262.  * Parameters:
  263.  *  pmkRight        LPMONIKER of the moniker to store on the right.
  264.  *  fOnlyIfNotGen   BOOL that contrls what should be done if the
  265.  *                  result is not a generic composite.
  266.  *  ppmkComposite   LPMONIKER * in which to store the resulting
  267.  *                  composite.
  268.  */
  269.  
  270. STDMETHODIMP CImpIMoniker::ComposeWith(LPMONIKER pmkRight
  271.     , BOOL fOnlyIfNotGen, LPMONIKER *ppmkComposite)
  272.     {
  273.     return ResultFromScode(E_NOTIMPL);
  274.     }
  275.  
  276.  
  277.  
  278.  
  279.  
  280.  
  281. /*
  282.  * CImpIMoniker::Enum
  283.  *
  284.  * Purpose:
  285.  *  Enumerates the monikers within this moniker if we are a
  286.  *  composite.  Need not be implemented for simple monikers.
  287.  *
  288.  * Parameters:
  289.  *  fForward        Specifies the direction of enumeration, TRUE
  290.  *                  for forward, FALSE for backwards.
  291.  *  ppEnum          LPENUMMONIKER * in which to store the
  292.  *                  enumerator's IEnumMoniker interface.
  293.  */
  294.  
  295. STDMETHODIMP CImpIMoniker::Enum(BOOL fForward, LPENUMMONIKER *ppEnum)
  296.     {
  297.     return ResultFromScode(E_NOTIMPL);
  298.     }
  299.  
  300.  
  301.  
  302.  
  303.  
  304.  
  305. /*
  306.  * CImpIMoniker::IsEqual
  307.  *
  308.  * Purpose:
  309.  *  Compares this moniker to another for equivalence.
  310.  *
  311.  * Parameters:
  312.  *  pmk             LPMONKIER to the other moniker to compare.
  313.  *
  314.  * Return Value:
  315.  *  HRESULT         S_OK or S_FALSE depending on the result of
  316.  *                  the comparison.
  317.  */
  318.  
  319. STDMETHODIMP CImpIMoniker::IsEqual(LPMONIKER pmk)
  320.     {
  321.     return ResultFromScode(E_NOTIMPL);
  322.     }
  323.  
  324.  
  325.  
  326.  
  327.  
  328.  
  329. /*
  330.  * CImpIMoniker::Hash
  331.  *
  332.  * Purpose:
  333.  *  Returns a 32-bit integer associated with this moniker that
  334.  *  can be used in creating moniker tables.  This should only rely
  335.  *  on the internal state of the moniker and not any memory
  336.  *  addresses.
  337.  *
  338.  * Parameters:
  339.  *  pdwHash         LPDWORD in which to store the hash number.
  340.  */
  341.  
  342. STDMETHODIMP CImpIMoniker::Hash(LPDWORD pdwHash)
  343.     {
  344.     return ResultFromScode(E_NOTIMPL);
  345.     }
  346.  
  347.  
  348.  
  349.  
  350.  
  351.  
  352. /*
  353.  * CImpIMoniker::IsRunning
  354.  *
  355.  * Purpose:
  356.  *  Tests if the object associated with this moniker is already
  357.  *  running.
  358.  *
  359.  * Parameters:
  360.  *  pBindCtx        LPBINDCTX to the bind context in use.
  361.  *  pmkLeft         LPMONIKER to the left.
  362.  *  pmkNewlyRunning LPMONIKER most recently added to the running
  363.  *                  object table (can be NULL).  If equivalent to
  364.  *                  this moniker then the object is already running.
  365.  *
  366.  * Return Value:
  367.  *  HRESULT         S_OK or S_FALSE (or an error code)
  368.  */
  369.  
  370. STDMETHODIMP CImpIMoniker::IsRunning(LPBC pBindCtx
  371.     , LPMONIKER pmkLeft, LPMONIKER pmkNewlyRunning)
  372.     {
  373.     return ResultFromScode(E_NOTIMPL);
  374.     }
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381. /*
  382.  * CImpIMoniker::GetTimeOfLastChange
  383.  *
  384.  * Purpose:
  385.  *  Reports the time that the object referenced by this moniker,
  386.  *  such as a file, changed.
  387.  *
  388.  * Parameters:
  389.  *  pBindCtx        LPBINDCTX to the bind context in use.
  390.  *  pmkLeft         LPMONIKER to the left.
  391.  *  pTime           FILETIME * in which to store the last change
  392.  *                  time and date information.
  393.  */
  394.  
  395. STDMETHODIMP CImpIMoniker::GetTimeOfLastChange(LPBC pBindCtx
  396.     , LPMONIKER pmkLeft, FILETIME *pTime)
  397.     {
  398.     return ResultFromScode(E_NOTIMPL);
  399.     }
  400.  
  401.  
  402.  
  403.  
  404.  
  405.  
  406. /*
  407.  * CImpIMoniker::Inverse
  408.  *
  409.  * Purpose:
  410.  *  Creates an inverse of this moniker such that a composite
  411.  *  containing this moniker and its inverse to the right would
  412.  *  annihilate each other.
  413.  *
  414.  * Parameters:
  415.  *  ppmkInverse     LPMONIKER * in which to store the inverse.
  416.  */
  417.  
  418. STDMETHODIMP CImpIMoniker::Inverse(LPMONIKER *)
  419.     {
  420.     return ResultFromScode(E_NOTIMPL);
  421.     }
  422.  
  423.  
  424.  
  425.  
  426.  
  427.  
  428. /*
  429.  * CImpIMoniker::CommonPrefixWith
  430.  *
  431.  * Purpose:
  432.  *  Determines if this moniker and another have a common prefix
  433.  *  (left elements) that can be separated out into another
  434.  *  moniker.
  435.  *
  436.  * Parameters:
  437.  *  pmk             LPMONIKER to the other moniker.
  438.  *  ppmkPrefix      LPMONIKER * in which to store the prefix moniker
  439.  *                  if there is one, otherwise receives NULL.
  440.  */
  441.  
  442. STDMETHODIMP CImpIMoniker::CommonPrefixWith(LPMONIKER, LPMONIKER *)
  443.     {
  444.     return ResultFromScode(E_NOTIMPL);
  445.     }
  446.  
  447.  
  448.  
  449.  
  450.  
  451. /*
  452.  * CImpIMoniker::RelativePathTo
  453.  *
  454.  * Purpose:
  455.  *  Returns another moniker that contains the relative path between
  456.  *  this moniker and another.
  457.  *
  458.  * Parameters:
  459.  *  pmk             LPMONIKER of the other moniker.
  460.  *  ppmkRelative    LPMONIKER * in which to store a moniker that
  461.  *                  contains the relative path.
  462.  */
  463.  
  464. STDMETHODIMP CImpIMoniker::RelativePathTo(LPMONIKER, LPMONIKER *)
  465.     {
  466.     return ResultFromScode(E_NOTIMPL);
  467.     }
  468.  
  469.  
  470.  
  471.  
  472.  
  473. /*
  474.  * CImpIMoniker::GetDisplayName
  475.  *
  476.  * Purpose:
  477.  *  Returns a human-readable name suitable for display of this
  478.  *  moniker.
  479.  *
  480.  * Parameters:
  481.  *  pBindCtx        LPBC to the current bind context.
  482.  *  pmkLeft         LPMONIKER to the left.
  483.  *  ppszName        LPOLESTR * in which to store the display name.
  484.  *                  Output can be NULL if there is no name.
  485.  */
  486.  
  487. STDMETHODIMP CImpIMoniker::GetDisplayName(LPBC, LPMONIKER, LPOLESTR *)
  488.     {
  489.     return ResultFromScode(E_NOTIMPL);
  490.     }
  491.  
  492.  
  493.  
  494.  
  495.  
  496. /*
  497.  * CImpIMoniker::ParseDisplayName
  498.  *
  499.  * Purpose:
  500.  *  Pparses the moniker's remaining display name. The pszDisplayName
  501.  *  parameter is the yet-to-be-parsed tail of the display name.  This
  502.  *  function parses as much of the remaining tail as is appropriate
  503.  *  for a display name within the object identified by
  504.  *  (pmkToLeft * (the receiver)) and returns the corresponding
  505.  *  moniker.
  506.  *
  507.  * Parameters:
  508.  *  pBindCtx        LPBC to the current bind context.
  509.  *  pmkLeft         LPMONIKER to the left.
  510.  *  pszDisplayName  LPOLESTR to the display name to be parsed.
  511.  *  pchEaten        ULONG * with the number of characters of the
  512.  *                  input name this parse consumed.
  513.  *  ppmkOut         LPMONIKER in whic to store the resulting
  514.  *                  moniker.
  515.  *
  516.  */
  517.  
  518. STDMETHODIMP CImpIMoniker::ParseDisplayName(LPBC pBindCtx
  519.     , LPMONIKER pmkLeft, LPOLESTR pszDisplayName, ULONG *pchEaten
  520.     , LPMONIKER *ppmkOut)
  521.     {
  522.     return ResultFromScode(E_NOTIMPL);
  523.     }
  524.  
  525.  
  526.  
  527.  
  528.  
  529. /*
  530.  * CImpIMoniker::IsSystemMoniker
  531.  *
  532.  * Purpose:
  533.  *  Returns whether or not this is a system-implemented moniker
  534.  *  whose implemented semantics are important for the binding
  535.  *  process.
  536.  *
  537.  * Parameters:
  538.  *  pdwType         LPDWORD in which to return the system moniker
  539.  *                  type, from the MKSYS enumeration if S_OK is
  540.  *                  returned.
  541.  *
  542.  * Return Value:
  543.  *  HRESULT         S_OK or S_FALSE.
  544.  */
  545.  
  546. STDMETHODIMP CImpIMoniker::IsSystemMoniker(LPDWORD)
  547.     {
  548.     return ResultFromScode(E_NOTIMPL);
  549.     }
  550.