home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 February / CHIP_2_98.iso / software / pelne / optionp / iis4_07.cab / simple.cpp < prev    next >
C/C++ Source or Header  |  1997-10-25  |  2KB  |  74 lines

  1. // Simple.cpp : Implementation of CSimple
  2.  
  3. #include "stdafx.h"
  4. #include "CATLSmpl.h"
  5. #include "Simple.h"
  6.  
  7. /////////////////////////////////////////////////////////////////////////////
  8. //
  9.  
  10. // Created by the ATL 1.1 COM Wizard
  11. STDMETHODIMP CSimple::InterfaceSupportsErrorInfo(REFIID riid)
  12. {
  13.     static const IID* arr[] = 
  14.     {
  15.         &IID_ISimple,
  16.     };
  17.  
  18.     for (int i=0;i<sizeof(arr)/sizeof(arr[0]);i++)
  19.     {
  20.         if (InlineIsEqualGUID(*arr[i],riid))
  21.             return S_OK;
  22.     }
  23.     return S_FALSE;
  24. }
  25.  
  26. //Ctor
  27. CSimple::CSimple()
  28.     : m_bstrMyProperty(OLESTR("C++ ATL Simple Component"))
  29. {}
  30.  
  31. //Put function for myProperty
  32. STDMETHODIMP CSimple::put_myProperty(BSTR bstrInValue)
  33. {
  34.     if (bstrInValue == NULL)
  35.         return E_POINTER;
  36.  
  37.     m_bstrMyProperty = bstrInValue;
  38.  
  39.     return S_OK;
  40. }
  41.  
  42. //Get function for myProperty
  43. STDMETHODIMP CSimple::get_myProperty(BSTR* pbstrOutValue)
  44. {
  45.     if (pbstrOutValue == NULL)
  46.         return E_POINTER;
  47.  
  48.     // Get Value from Property
  49.     *pbstrOutValue = m_bstrMyProperty.Copy();
  50.     
  51.     return S_OK;
  52. }
  53.  
  54. //Basic Method to convert a string to uppercase
  55. STDMETHODIMP CSimple::myMethod(BSTR bstrIn, BSTR* pbstrOut)  
  56. {
  57.     if (bstrIn == NULL || pbstrOut == NULL)
  58.         return E_POINTER;
  59.  
  60.     // Create a temporary CComBSTR
  61.     CComBSTR bstrTemp(bstrIn);
  62.  
  63.     if (!bstrTemp)
  64.         return E_OUTOFMEMORY;
  65.  
  66.     // Make string uppercase   
  67.     wcsupr(bstrTemp);  
  68.     
  69.     // Return m_str member of bstrTemp
  70.     *pbstrOut = bstrTemp.Detach();
  71.  
  72.     return S_OK;
  73. }
  74.