home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / dbmsg / mapi / flatfile.ab / wrap.c < prev   
Encoding:
C/C++ Source or Header  |  1996-04-11  |  22.5 KB  |  965 lines

  1. /***********************************************************************
  2.  *
  3.  *  WRAP.C
  4.  *
  5.  *  Sample Address Book Wrap object
  6.  *  This file contains the code for implementing the Sample AB
  7.  *  WRAP object.
  8.  *
  9.  *  This file contains methods with "default" actions for objects which
  10.  *  expose IUnknown and/or IMAPIProp.  These "default" actions are to call
  11.  *  the appropriate method of a "wrapped" object that is a member of this
  12.  *  object.  Various methods in this file are used throughout this sample
  13.  *  provider and are especially useful with the objects that implement template
  14.  *  ids (see TID.C and OOTID.C).
  15.  *
  16.  *  Copyright 1992-1995 Microsoft Corporation.  All Rights Reserved.
  17.  *
  18.  ***********************************************************************/
  19.  
  20. #include "abp.h"
  21.  
  22. typedef struct _WRAP {
  23.  
  24.     WRAP_Vtbl * lpVtbl;
  25.  
  26.     SAB_Wrapped;
  27.     
  28. } WRAP, *LPWRAP;
  29.  
  30. /*********************************************************************
  31.  *
  32.  *  The actual Wrapped IMAPIProp methods
  33.  *
  34.  */
  35.  
  36. STDMETHODIMP
  37. WRAP_QueryInterface(LPWRAP lpWRAP,
  38.                     REFIID lpiid,
  39.                     LPVOID * lppNewObj)
  40. {
  41.     HRESULT hr;
  42.  
  43.     /*
  44.      *  Check to see if it has a lpVtbl object member
  45.      */
  46.     if (IsBadReadPtr(lpWRAP, offsetof(WRAP, lpVtbl)+sizeof(WRAP_Vtbl *)))
  47.     {
  48.         /*
  49.          *  No jump table found
  50.          */
  51.         return ResultFromScode(E_INVALIDARG);
  52.     }
  53.  
  54.     /*
  55.      *  Check to see that the Vtbl is large enough to include this method
  56.      */
  57.     if (IsBadReadPtr(lpWRAP->lpVtbl,
  58.                      offsetof(WRAP_Vtbl, QueryInterface)+sizeof(WRAP_QueryInterface_METHOD *)))
  59.     {
  60.         /*
  61.          *  Jump table not derived from IUnknown
  62.          */
  63.         return ResultFromScode(E_INVALIDARG);
  64.     }
  65.  
  66.     /*
  67.      *  Check to see if the method is the same
  68.      */
  69.     if (WRAP_QueryInterface != lpWRAP->lpVtbl->QueryInterface)
  70.     {
  71.         /*
  72.          *  Wrong object - the object passed doesn't have this
  73.          *  method.
  74.          */
  75.         return ResultFromScode(E_INVALIDARG);
  76.     }
  77.  
  78.     EnterCriticalSection(&lpWRAP->cs);
  79.     /*  Call the internal prop interface */
  80.  
  81.     hr = lpWRAP->lpPropData->lpVtbl->QueryInterface(
  82.         lpWRAP->lpPropData,
  83.         lpiid,
  84.         lppNewObj);
  85.  
  86.     /*  If this object is successful in QI'ing and it returns exactly the
  87.      *  same object, then I need to AddRef my own "wrapper" object so that
  88.      *  my release code works correctly AND replace the *lppNewObj with the
  89.      *  "wrapper" object.
  90.      */
  91.     if (!HR_FAILED(hr) && (lpWRAP->lpPropData == *lppNewObj))
  92.     {
  93.         ++lpWRAP->lcInit;
  94.         *lppNewObj = lpWRAP;
  95.     }
  96.  
  97.     LeaveCriticalSection(&lpWRAP->cs);
  98.  
  99.     return hr;
  100.  
  101. }
  102.  
  103. STDMETHODIMP_(ULONG) WRAP_AddRef(LPWRAP lpWRAP)
  104. {
  105.     ULONG ulRet;
  106.     /*
  107.      *  Check to see if it has a lpVtbl object member
  108.      */
  109.     if (IsBadReadPtr(lpWRAP, offsetof(WRAP, lpVtbl)+sizeof(WRAP_Vtbl *)))
  110.     {
  111.         /*
  112.          *  No jump table found
  113.          */
  114.         return 1;
  115.     }
  116.  
  117.     /*
  118.      *  Check to see that the Vtbl is large enough to include this method
  119.      */
  120.     if (IsBadReadPtr(lpWRAP->lpVtbl,
  121.                      offsetof(WRAP_Vtbl, AddRef)+sizeof(WRAP_AddRef_METHOD *)))
  122.     {
  123.         /*
  124.          *  Jump table not derived from IUnknown
  125.          */
  126.         return 1;
  127.     }
  128.  
  129.     /*
  130.      *  Check to see if the method is the same
  131.      */
  132.     if (WRAP_AddRef != lpWRAP->lpVtbl->AddRef)
  133.     {
  134.         /*
  135.          *  Wrong object - the object passed doesn't have this
  136.          *  method.
  137.          */
  138.         return 1;
  139.     }
  140.  
  141.     EnterCriticalSection(&lpWRAP->cs);
  142.     ++lpWRAP->lcInit;
  143.  
  144.     /*  Call the internal prop interface */
  145.  
  146.     ulRet = lpWRAP->lpPropData->lpVtbl->AddRef(lpWRAP->lpPropData);
  147.     
  148.     LeaveCriticalSection(&lpWRAP->cs);
  149.  
  150.     return ulRet;
  151. }
  152.  
  153. STDMETHODIMP_(ULONG) WRAP_Release(LPWRAP lpWRAP)
  154. {
  155.     long lcInit;
  156.     /*
  157.      *  Check to see if it has a lpVtbl object member
  158.      */
  159.     if (IsBadReadPtr(lpWRAP, offsetof(WRAP, lpVtbl)+sizeof(WRAP_Vtbl *)))
  160.     {
  161.         /*
  162.          *  No jump table found
  163.          */
  164.         return 1;
  165.     }
  166.  
  167.     /*
  168.      *  Check to see that the Vtbl is large enough to include this method
  169.      */
  170.     if (IsBadReadPtr(lpWRAP->lpVtbl,
  171.                      offsetof(WRAP_Vtbl, Release)+sizeof(WRAP_Release_METHOD *)))
  172.     {
  173.         /*
  174.          *  Jump table not derived from IUnknown
  175.          */
  176.         return 1;
  177.     }
  178.  
  179.     /*
  180.      *  Check to see if the method is the same
  181.      */
  182.     if (WRAP_Release != lpWRAP->lpVtbl->Release)
  183.     {
  184.         /*
  185.          *  Wrong object - the object passed doesn't have this
  186.          *  method.
  187.          */
  188.         return 1;
  189.     }
  190.  
  191.  
  192.     EnterCriticalSection(&lpWRAP->cs);
  193.  
  194.     /*
  195.      *  Release the imapiprop object
  196.      */
  197.  
  198.     lpWRAP->lpPropData->lpVtbl->Release(
  199.         lpWRAP->lpPropData);
  200.  
  201.     lcInit = --lpWRAP->lcInit;
  202.  
  203.     LeaveCriticalSection(&lpWRAP->cs);
  204.  
  205.     if (lcInit == 0)
  206.     {
  207.         /*  
  208.          *  Release our reference to the ABLogon object.
  209.          */
  210.         if (lpWRAP->lpABLogon)
  211.         {
  212.             lpWRAP->lpABLogon->lpVtbl->Release(lpWRAP->lpABLogon);
  213.             lpWRAP->lpABLogon = NULL;
  214.         }
  215.  
  216.  
  217.         /*
  218.          *  Get rid of my critical section
  219.          */
  220.         DeleteCriticalSection(&lpWRAP->cs);
  221.  
  222.         /*
  223.          *  Set the Jump table to NULL.  This way the client will find out
  224.          *  real fast if it's calling a method on a released object.  That is,
  225.          *  the client will crash.  Hopefully, this will happen during the
  226.          *  development stage of the client.
  227.          */
  228.  
  229.         lpWRAP->lpVtbl = NULL;
  230.  
  231.         /*
  232.          *  Need to free the object
  233.          */
  234.  
  235.         lpWRAP->lpFreeBuff(lpWRAP);
  236.         return 0;
  237.     }
  238.  
  239.     return lcInit;
  240. }
  241.  
  242. STDMETHODIMP
  243. WRAP_GetLastError(  LPWRAP lpWRAP,
  244.                     HRESULT hError,
  245.                     ULONG ulFlags,
  246.                     LPMAPIERROR FAR * lppMapiError )
  247. {
  248.     HRESULT hResult;
  249.  
  250.     /*
  251.      *  Check to see if it has a lpVtbl object member
  252.      */
  253.     if (IsBadReadPtr(lpWRAP, offsetof(WRAP, lpVtbl)+sizeof(WRAP_Vtbl *)))
  254.     {
  255.         /*
  256.          *  No jump table found
  257.          */
  258.         hResult = ResultFromScode(E_INVALIDARG);
  259.  
  260.         return hResult;
  261.     }
  262.  
  263.     /*
  264.      *  Check to see that the Vtbl is large enough to include this method
  265.      */
  266.     if (IsBadReadPtr(lpWRAP->lpVtbl,
  267.         offsetof(WRAP_Vtbl, GetLastError)+sizeof(WRAP_GetLastError_METHOD *)))
  268.     {
  269.         /*
  270.          *  Jump table not derived from IUnknown
  271.          */
  272.  
  273.         hResult = ResultFromScode(E_INVALIDARG);
  274.  
  275.         return hResult;
  276.     }
  277.  
  278.     /*
  279.      *  Check to see if the method is the same
  280.      */
  281.     if (WRAP_GetLastError != lpWRAP->lpVtbl->GetLastError)
  282.     {
  283.         /*
  284.          *  Wrong object - the object passed doesn't have this
  285.          *  method.
  286.          */
  287.  
  288.         hResult = ResultFromScode(E_INVALIDARG);
  289.  
  290.         return hResult;
  291.     }
  292.  
  293.     if ( ulFlags & ~MAPI_UNICODE )
  294.     {
  295.         hResult = ResultFromScode( MAPI_E_UNKNOWN_FLAGS );
  296.         return hResult ;
  297.     }
  298.     
  299.     if ( ulFlags & MAPI_UNICODE )
  300.     {
  301.         hResult = ResultFromScode( MAPI_E_BAD_CHARWIDTH );
  302.         return hResult;
  303.     }
  304.     
  305.     return lpWRAP->lpPropData->lpVtbl->GetLastError(
  306.         lpWRAP->lpPropData,
  307.         hError,
  308.         ulFlags,
  309.         lppMapiError );
  310. }
  311.  
  312. /* IProperty */
  313.  
  314. STDMETHODIMP
  315. WRAP_SaveChanges(   LPWRAP lpWRAP,
  316.                     ULONG ulFlags)
  317. {
  318.     HRESULT hResult;
  319.  
  320.     /*
  321.      *  Check to see if it has a lpVtbl object member
  322.      */
  323.     if (IsBadReadPtr(lpWRAP, offsetof(WRAP, lpVtbl)+sizeof(WRAP_Vtbl *)))
  324.     {
  325.         /*
  326.          *  No jump table found
  327.          */
  328.         hResult = ResultFromScode(E_INVALIDARG);
  329.  
  330.         return hResult;
  331.     }
  332.  
  333.     /*
  334.      *  Check to see that the Vtbl is large enough to include this method
  335.      */
  336.     if (IsBadReadPtr(lpWRAP->lpVtbl,
  337.                      offsetof(WRAP_Vtbl, SaveChanges)+sizeof(WRAP_SaveChanges_METHOD *)))
  338.     {
  339.         /*
  340.          *  Jump table not derived from IUnknown
  341.          */
  342.  
  343.         hResult = ResultFromScode(E_INVALIDARG);
  344.  
  345.         return hResult;
  346.     }
  347.  
  348.     /*
  349.      *  Check to see if the method is the same
  350.      */
  351.     if (WRAP_SaveChanges != lpWRAP->lpVtbl->SaveChanges)
  352.     {
  353.         /*
  354.          *  Wrong object - the object passed doesn't have this
  355.          *  method.
  356.          */
  357.  
  358.         hResult = ResultFromScode(E_INVALIDARG);
  359.  
  360.         return hResult;
  361.     }
  362.  
  363.     hResult = lpWRAP->lpPropData->lpVtbl->SaveChanges(
  364.         lpWRAP->lpPropData,
  365.         ulFlags);
  366.  
  367.     return hResult;
  368.  
  369. }
  370.  
  371. STDMETHODIMP
  372. WRAP_GetProps(  LPWRAP lpWRAP,
  373.                 LPSPropTagArray lpPropTagArray,
  374.                 ULONG ulFlags,
  375.                 ULONG * lpcValues,
  376.                 LPSPropValue * lppPropArray)
  377. {
  378.     HRESULT hResult;
  379.  
  380.     /*
  381.      *  Check to see if it has a lpVtbl object member
  382.      */
  383.     if (IsBadReadPtr(lpWRAP, offsetof(WRAP, lpVtbl)+sizeof(WRAP_Vtbl *)))
  384.     {
  385.         /*
  386.          *  No jump table found
  387.          */
  388.         hResult = ResultFromScode(E_INVALIDARG);
  389.  
  390.         return hResult;
  391.     }
  392.  
  393.     /*
  394.      *  Check to see that the Vtbl is large enough to include this method
  395.      */
  396.     if (IsBadReadPtr(lpWRAP->lpVtbl,
  397.                      offsetof(WRAP_Vtbl, GetProps)+sizeof(WRAP_GetProps_METHOD *)))
  398.     {
  399.         /*
  400.          *  Jump table not derived from IUnknown
  401.          */
  402.  
  403.         hResult = ResultFromScode(E_INVALIDARG);
  404.  
  405.         return hResult;
  406.     }
  407.  
  408.     /*
  409.      *  Check to see if the method is the same
  410.      */
  411.     if (WRAP_GetProps != lpWRAP->lpVtbl->GetProps)
  412.     {
  413.         /*
  414.          *  Wrong object - the object passed doesn't have this
  415.          *  method.
  416.          */
  417.  
  418.         hResult = ResultFromScode(E_INVALIDARG);
  419.  
  420.         return hResult;
  421.     }
  422.  
  423.     if ( ulFlags & ~(MAPI_UNICODE) )
  424.     {
  425.         hResult = ResultFromScode( MAPI_E_UNKNOWN_FLAGS );
  426.         
  427.         return hResult;
  428.     }
  429.     
  430.     if ( ulFlags & MAPI_UNICODE )
  431.     {
  432.         hResult = ResultFromScode( MAPI_E_BAD_CHARWIDTH );
  433.         return hResult;
  434.     }
  435.  
  436.     return lpWRAP->lpPropData->lpVtbl->GetProps(
  437.         lpWRAP->lpPropData,
  438.         lpPropTagArray,
  439.         ulFlags,
  440.         lpcValues,
  441.         lppPropArray);
  442.  
  443. }
  444.  
  445. STDMETHODIMP
  446. WRAP_GetPropList(   LPWRAP lpWRAP,
  447.                     ULONG ulFlags,
  448.                     LPSPropTagArray * lppPropTagArray)
  449. {
  450.     HRESULT hResult = hrSuccess;
  451.  
  452.     /*
  453.      *  Check to see if it has a lpVtbl object member
  454.      */
  455.     if (IsBadReadPtr(lpWRAP, offsetof(WRAP, lpVtbl)+sizeof(WRAP_Vtbl *)))
  456.     {
  457.         /*
  458.          *  No jump table found
  459.          */
  460.         hResult = ResultFromScode(E_INVALIDARG);
  461.  
  462.         return hResult;
  463.     }
  464.  
  465.     /*
  466.      *  Check to see that the Vtbl is large enough to include this method
  467.      */
  468.     if (IsBadReadPtr(lpWRAP->lpVtbl,
  469.                      offsetof(WRAP_Vtbl, GetPropList)+sizeof(WRAP_GetPropList_METHOD *)))
  470.     {
  471.         /*
  472.          *  Jump table not derived from IUnknown
  473.          */
  474.  
  475.         hResult = ResultFromScode(E_INVALIDARG);
  476.  
  477.         return hResult;
  478.     }
  479.  
  480.     /*
  481.      *  Check to see if the method is the same
  482.      */
  483.     if (WRAP_GetPropList != lpWRAP->lpVtbl->GetPropList)
  484.     {
  485.         /*
  486.          *  Wrong object - the object passed doesn't have this
  487.          *  method.
  488.          */
  489.  
  490.         hResult = ResultFromScode(E_INVALIDARG);
  491.  
  492.         return hResult;
  493.     }
  494.  
  495.     if ( ulFlags & ~(MAPI_UNICODE) )
  496.     {
  497.         hResult = ResultFromScode( MAPI_E_UNKNOWN_FLAGS );
  498.         
  499.         return hResult;
  500.     }
  501.     
  502.     if ( ulFlags & MAPI_UNICODE )
  503.     {
  504.         hResult = ResultFromScode( MAPI_E_BAD_CHARWIDTH );
  505.         return hResult;
  506.     }
  507.     
  508.     return lpWRAP->lpPropData->lpVtbl->GetPropList(
  509.         lpWRAP->lpPropData,
  510.         ulFlags,
  511.         lppPropTagArray);
  512.  
  513. }
  514.  
  515. STDMETHODIMP
  516. WRAP_OpenProperty(  LPWRAP lpWRAP,
  517.                     ULONG ulPropTag,
  518.                     LPCIID lpiid,
  519.                     ULONG ulInterfaceOptions,
  520.                     ULONG ulFlags,
  521.                     LPUNKNOWN * lppUnk)
  522. {
  523.     HRESULT hResult;
  524.  
  525.     /*
  526.      *  Check to see if it has a lpVtbl object member
  527.      */
  528.     if (IsBadReadPtr(lpWRAP, offsetof(WRAP, lpVtbl)+sizeof(WRAP_Vtbl *)))
  529.     {
  530.         /*
  531.          *  No jump table found
  532.          */
  533.         hResult = ResultFromScode(E_INVALIDARG);
  534.  
  535.         return hResult;
  536.     }
  537.  
  538.     /*
  539.      *  Check to see that the Vtbl is large enough to include this method
  540.      */
  541.     if (IsBadReadPtr(lpWRAP->lpVtbl,
  542.                      offsetof(WRAP_Vtbl, OpenProperty)+sizeof(WRAP_OpenProperty_METHOD *)))
  543.     {
  544.         /*
  545.          *  Jump table not derived from IUnknown
  546.          */
  547.  
  548.         hResult = ResultFromScode(E_INVALIDARG);
  549.  
  550.         return hResult;
  551.     }
  552.  
  553.     /*
  554.      *  Check to see if the method is the same
  555.      */
  556.     if (WRAP_OpenProperty != lpWRAP->lpVtbl->OpenProperty)
  557.     {
  558.         /*
  559.          *  Wrong object - the object passed doesn't have this
  560.          *  method.
  561.          */
  562.  
  563.         hResult = ResultFromScode(E_INVALIDARG);
  564.  
  565.         return hResult;
  566.     }
  567.     
  568.     if ( ulInterfaceOptions & ~MAPI_UNICODE )
  569.     {
  570.         hResult = ResultFromScode( MAPI_E_UNKNOWN_FLAGS );
  571.         return hResult;
  572.     }
  573.     
  574.     if ( ulInterfaceOptions & MAPI_UNICODE )
  575.     {
  576.         hResult = ResultFromScode( MAPI_E_BAD_CHARWIDTH );
  577.         return hResult;
  578.     }
  579.     
  580.     hResult = lpWRAP->lpPropData->lpVtbl->OpenProperty(
  581.         lpWRAP->lpPropData,
  582.         ulPropTag,
  583.         lpiid,
  584.         ulInterfaceOptions,
  585.         ulFlags,
  586.         lppUnk);
  587.  
  588.     return hResult;
  589.  
  590. }
  591.  
  592. STDMETHODIMP
  593. WRAP_SetProps(  LPWRAP lpWRAP,
  594.                 ULONG cValues,
  595.                 LPSPropValue lpPropArray,
  596.                 LPSPropProblemArray * lppProblems)
  597. {
  598.     HRESULT hResult;
  599.  
  600.     /*
  601.      *  Check to see if it has a lpVtbl object member
  602.      */
  603.     if (IsBadReadPtr(lpWRAP, offsetof(WRAP, lpVtbl)+sizeof(WRAP_Vtbl *)))
  604.     {
  605.         /*
  606.          *  No jump table found
  607.          */
  608.         hResult = ResultFromScode(E_INVALIDARG);
  609.  
  610.         return hResult;
  611.     }
  612.  
  613.     /*
  614.      *  Check to see that the Vtbl is large enough to include this method
  615.      */
  616.     if (IsBadReadPtr(lpWRAP->lpVtbl,
  617.                      offsetof(WRAP_Vtbl, SetProps)+sizeof(WRAP_SetProps_METHOD *)))
  618.     {
  619.         /*
  620.          *  Jump table not derived from IUnknown
  621.          */
  622.  
  623.         hResult = ResultFromScode(E_INVALIDARG);
  624.  
  625.         return hResult;
  626.     }
  627.  
  628.     /*
  629.      *  Check to see if the method is the same
  630.      */
  631.     if (WRAP_SetProps != lpWRAP->lpVtbl->SetProps)
  632.     {
  633.         /*
  634.          *  Wrong object - the object passed doesn't have this
  635.          *  method.
  636.          */
  637.  
  638.         hResult = ResultFromScode(E_INVALIDARG);
  639.  
  640.         return hResult;
  641.     }
  642.  
  643.     return lpWRAP->lpPropData->lpVtbl->SetProps(
  644.         lpWRAP->lpPropData,
  645.         cValues,
  646.         lpPropArray,
  647.         lppProblems);
  648.  
  649. }
  650.  
  651. STDMETHODIMP
  652. WRAP_DeleteProps(   LPWRAP lpWRAP,
  653.                     LPSPropTagArray lpPropTagArray,
  654.                     LPSPropProblemArray * lppProblems)
  655. {
  656.     HRESULT hResult;
  657.  
  658.     /*
  659.      *  Check to see if it has a lpVtbl object member
  660.      */
  661.     if (IsBadReadPtr(lpWRAP, offsetof(WRAP, lpVtbl)+sizeof(WRAP_Vtbl *)))
  662.     {
  663.         /*
  664.          *  No jump table found
  665.          */
  666.         hResult = ResultFromScode(E_INVALIDARG);
  667.  
  668.         return hResult;
  669.     }
  670.  
  671.     /*
  672.      *  Check to see that the Vtbl is large enough to include this method
  673.      */
  674.     if (IsBadReadPtr(lpWRAP->lpVtbl,
  675.                      offsetof(WRAP_Vtbl, DeleteProps)+sizeof(WRAP_DeleteProps_METHOD *)))
  676.     {
  677.         /*
  678.          *  Jump table not derived from IUnknown
  679.          */
  680.  
  681.         hResult = ResultFromScode(E_INVALIDARG);
  682.  
  683.         return hResult;
  684.     }
  685.  
  686.     /*
  687.      *  Check to see if the method is the same
  688.      */
  689.     if (WRAP_DeleteProps != lpWRAP->lpVtbl->DeleteProps)
  690.     {
  691.         /*
  692.          *  Wrong object - the object passed doesn't have this
  693.          *  method.
  694.          */
  695.  
  696.         hResult = ResultFromScode(E_INVALIDARG);
  697.  
  698.         return hResult;
  699.     }
  700.  
  701.     return lpWRAP->lpPropData->lpVtbl->DeleteProps(
  702.         lpWRAP->lpPropData,
  703.         lpPropTagArray,
  704.         lppProblems);
  705.  
  706. }
  707.  
  708. STDMETHODIMP
  709. WRAP_CopyTo(LPWRAP lpWRAP,
  710.             ULONG ciidExclude,
  711.             LPCIID rgiidExclude,
  712.             LPSPropTagArray lpExcludeProps,
  713.             ULONG ulUIParam,
  714.             LPMAPIPROGRESS lpProgress,
  715.             LPCIID lpInterface,
  716.             LPVOID lpDestObj,
  717.             ULONG ulFlags,
  718.             LPSPropProblemArray FAR * lppProblems)
  719. {
  720.     HRESULT hResult;
  721.  
  722.     /*
  723.      *  Check to see if it has a lpVtbl object member
  724.      */
  725.     if (IsBadReadPtr(lpWRAP, offsetof(WRAP, lpVtbl)+sizeof(WRAP_Vtbl *)))
  726.     {
  727.         /*
  728.          *  No jump table found
  729.          */
  730.         hResult = ResultFromScode(E_INVALIDARG);
  731.  
  732.         return hResult;
  733.     }
  734.  
  735.     /*
  736.      *  Check to see that the Vtbl is large enough to include this method
  737.      */
  738.     if (IsBadReadPtr(lpWRAP->lpVtbl,
  739.                      offsetof(WRAP_Vtbl, CopyTo)+sizeof(WRAP_CopyTo_METHOD *)))
  740.     {
  741.         /*
  742.          *  Jump table not derived from IUnknown
  743.          */
  744.  
  745.         hResult = ResultFromScode(E_INVALIDARG);
  746.  
  747.         return hResult;
  748.     }
  749.  
  750.     /*
  751.      *  Check to see if the method is the same
  752.      */
  753.     if (WRAP_CopyTo != lpWRAP->lpVtbl->CopyTo)
  754.     {
  755.         /*
  756.          *  Wrong object - the object passed doesn't have this
  757.          *  method.
  758.          */
  759.  
  760.         hResult = ResultFromScode(E_INVALIDARG);
  761.  
  762.         return hResult;
  763.     }
  764.  
  765.     return lpWRAP->lpPropData->lpVtbl->CopyTo(
  766.         lpWRAP->lpPropData,
  767.         ciidExclude,
  768.         rgiidExclude,
  769.         lpExcludeProps,
  770.         ulUIParam,
  771.         lpProgress,
  772.         lpInterface,
  773.         lpDestObj,
  774.         ulFlags,
  775.         lppProblems);
  776. }
  777.  
  778. STDMETHODIMP
  779. WRAP_CopyProps(LPWRAP lpWRAP,
  780.             LPSPropTagArray lpIncludeProps,
  781.             ULONG ulUIParam,
  782.             LPMAPIPROGRESS lpProgress,
  783.             LPCIID lpInterface,
  784.             LPVOID lpDestObj,
  785.             ULONG ulFlags,
  786.             LPSPropProblemArray FAR * lppProblems)
  787. {
  788.     HRESULT hResult;
  789.  
  790.     /*
  791.      *  Check to see if it has a lpVtbl object member
  792.      */
  793.     if (IsBadReadPtr(lpWRAP, offsetof(WRAP, lpVtbl)+sizeof(WRAP_Vtbl *)))
  794.     {
  795.         /*
  796.          *  No jump table found
  797.          */
  798.         hResult = ResultFromScode(E_INVALIDARG);
  799.  
  800.         return hResult;
  801.     }
  802.  
  803.     /*
  804.      *  Check to see that the Vtbl is large enough to include this method
  805.      */
  806.     if (IsBadReadPtr(lpWRAP->lpVtbl,
  807.                      offsetof(WRAP_Vtbl, CopyProps)+sizeof(WRAP_CopyProps_METHOD *)))
  808.     {
  809.         /*
  810.          *  Jump table not derived from IUnknown
  811.          */
  812.  
  813.         hResult = ResultFromScode(E_INVALIDARG);
  814.  
  815.         return hResult;
  816.     }
  817.  
  818.     /*
  819.      *  Check to see if the method is the same
  820.      */
  821.     if (WRAP_CopyProps != lpWRAP->lpVtbl->CopyProps)
  822.     {
  823.         /*
  824.          *  Wrong object - the object passed doesn't have this
  825.          *  method.
  826.          */
  827.  
  828.         hResult = ResultFromScode(E_INVALIDARG);
  829.  
  830.         return hResult;
  831.     }
  832.  
  833.     return lpWRAP->lpPropData->lpVtbl->CopyProps(
  834.         lpWRAP->lpPropData,
  835.         lpIncludeProps,
  836.         ulUIParam,
  837.         lpProgress,
  838.         lpInterface,
  839.         lpDestObj,
  840.         ulFlags,
  841.         lppProblems);
  842. }
  843.  
  844. STDMETHODIMP
  845. WRAP_GetNamesFromIDs(   LPWRAP lpWRAP,
  846.                         LPSPropTagArray * lppPropTags,
  847.                         LPGUID lpPropSetGuid,
  848.                         ULONG ulFlags,
  849.                         ULONG * lpcPropNames,
  850.                         LPMAPINAMEID ** lpppPropNames)
  851. {
  852.     HRESULT hResult;
  853.  
  854.     /*
  855.      *  Check to see if it has a lpVtbl object member
  856.      */
  857.     if (IsBadReadPtr(lpWRAP, offsetof(WRAP, lpVtbl)+sizeof(WRAP_Vtbl *)))
  858.     {
  859.         /*
  860.          *  No jump table found
  861.          */
  862.         hResult = ResultFromScode(E_INVALIDARG);
  863.  
  864.         return hResult;
  865.     }
  866.  
  867.     /*
  868.      *  Check to see that the Vtbl is large enough to include this method
  869.      */
  870.     if (IsBadReadPtr(lpWRAP->lpVtbl,
  871.                      offsetof(WRAP_Vtbl, GetNamesFromIDs)+sizeof(WRAP_GetNamesFromIDs_METHOD *)))
  872.     {
  873.         /*
  874.          *  Jump table not derived from IUnknown
  875.          */
  876.  
  877.         hResult = ResultFromScode(E_INVALIDARG);
  878.  
  879.         return hResult;
  880.     }
  881.  
  882.     /*
  883.      *  Check to see if the method is the same
  884.      */
  885.     if (WRAP_GetNamesFromIDs != lpWRAP->lpVtbl->GetNamesFromIDs)
  886.     {
  887.         /*
  888.          *  Wrong object - the object passed doesn't have this
  889.          *  method.
  890.          */
  891.  
  892.         hResult = ResultFromScode(E_INVALIDARG);
  893.  
  894.         return hResult;
  895.     }
  896.  
  897.     return lpWRAP->lpPropData->lpVtbl->GetNamesFromIDs(
  898.         lpWRAP->lpPropData,
  899.         lppPropTags,
  900.         lpPropSetGuid,
  901.         ulFlags,
  902.         lpcPropNames,
  903.         lpppPropNames);
  904. }
  905.  
  906. STDMETHODIMP
  907. WRAP_GetIDsFromNames(   LPWRAP lpWRAP,
  908.                         ULONG cPropNames,
  909.                         LPMAPINAMEID * lppPropNames,
  910.                         ULONG ulFlags,
  911.                         LPSPropTagArray * lppPropTags)
  912. {
  913.     HRESULT hResult;
  914.  
  915.     /*
  916.      *  Check to see if it has a lpVtbl object member
  917.      */
  918.     if (IsBadReadPtr(lpWRAP, offsetof(WRAP, lpVtbl)+sizeof(WRAP_Vtbl *)))
  919.     {
  920.         /*
  921.          *  No jump table found
  922.          */
  923.         hResult = ResultFromScode(E_INVALIDARG);
  924.  
  925.         return hResult;
  926.     }
  927.  
  928.     /*
  929.      *  Check to see that the Vtbl is large enough to include this method
  930.      */
  931.     if (IsBadReadPtr(lpWRAP->lpVtbl,
  932.                      offsetof(WRAP_Vtbl, GetIDsFromNames)+sizeof(WRAP_GetIDsFromNames_METHOD *)))
  933.     {
  934.         /*
  935.          *  Jump table not derived from IUnknown
  936.          */
  937.  
  938.         hResult = ResultFromScode(E_INVALIDARG);
  939.  
  940.         return hResult;
  941.     }
  942.  
  943.     /*
  944.      *  Check to see if the method is the same
  945.      */
  946.     if (WRAP_GetIDsFromNames != lpWRAP->lpVtbl->GetIDsFromNames)
  947.     {
  948.         /*
  949.          *  Wrong object - the object passed doesn't have this
  950.          *  method.
  951.          */
  952.  
  953.         hResult = ResultFromScode(E_INVALIDARG);
  954.  
  955.         return hResult;
  956.     }
  957.  
  958.     return lpWRAP->lpPropData->lpVtbl->GetIDsFromNames(
  959.         lpWRAP->lpPropData,
  960.         cPropNames,
  961.         lppPropNames,
  962.         ulFlags,
  963.         lppPropTags);
  964. }
  965.