home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 27 / IOPROG_27.ISO / SOFT / ADSDK.ZIP / Samples / Extension / Tutorial / step1 / HelloWorld.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-09-17  |  1.0 KB  |  58 lines

  1. // HelloWorld.cpp : Implementation of CADsFirstExtApp and DLL registration.
  2.  
  3. #include "stdafx.h"
  4. #include "ADsFirstExt.h"
  5. #include "HelloWorld.h"
  6.  
  7.  
  8. /////////////////////////////////////////////////////////////////////////////
  9. //
  10.  
  11. STDMETHODIMP HelloWorld::InterfaceSupportsErrorInfo(REFIID riid)
  12. {
  13.     static const IID* arr[] = 
  14.     {
  15.         &IID_IHelloWorld,
  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. STDMETHODIMP HelloWorld::Say()
  27. {
  28.     AFX_MANAGE_STATE(AfxGetStaticModuleState())
  29.  
  30.     IADs *pADs;
  31.     HRESULT hr;
  32.     BSTR    bstr;
  33.     TCHAR  szText[128];
  34.  
  35.  
  36.  
  37.     hr = OuterQueryInterface(IID_IADs, (void **) &pADs );
  38.     if ( !SUCCEEDED(hr) )
  39.     {
  40.         return hr;
  41.     }
  42.  
  43.     hr = pADs->get_Name(&bstr);
  44.     if ( !SUCCEEDED(hr) )
  45.     {
  46.         pADs->Release();
  47.         return hr;
  48.     }
  49.     wsprintf(szText, _T("Hello %S"), bstr );
  50.     SysFreeString(bstr);
  51.  
  52.  
  53.     ::MessageBox(NULL, szText, _T("From ADSI Extension"), MB_OK);
  54.     pADs->Release();
  55.  
  56.     return S_OK;
  57. }
  58.