home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 27 / IOPROG_27.ISO / SOFT / ADSDK.ZIP / Samples / Start / Parent / vc / Parent.cpp next >
Encoding:
C/C++ Source or Header  |  1999-01-19  |  973 b   |  50 lines

  1. // Parent.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "activeds.h"
  6.  
  7.  
  8. int main(int argc, char* argv[])
  9. {
  10.     HRESULT hr;
  11.  
  12.     CoInitialize(NULL);
  13.  
  14.     /////////////////////////////////////////
  15.     //Bind to an object
  16.     /////////////////////////////////////////
  17.     IADs *pADs = NULL;
  18.     hr = ADsGetObject(L"WinNT://INDEPENDENCE/JJohnson", IID_IADs, (void**) &pADs );
  19.     if (!SUCCEEDED(hr) )
  20.     {
  21.         return hr;
  22.     }
  23.  
  24.     BSTR bstrParent;
  25.     IADs *pParent=NULL;
  26.  
  27.     //////////////////////////////
  28.     // Get the ADs Parent's Path
  29.     //////////////////////////////
  30.     pADs->get_Parent(&bstrParent);
  31.     pADs->Release();
  32.  
  33.     ////////////////////////////////
  34.     // Bind to the Parent
  35.     ////////////////////////////////
  36.     hr = ADsGetObject( bstrParent, IID_IADs, (void**) &pParent );
  37.     SysFreeString(bstrParent);
  38.  
  39.  
  40.     if (SUCCEEDED(hr) )
  41.     {
  42.         // do something with pParent...
  43.         pParent->Release();
  44.     }
  45.  
  46.  
  47.     CoUninitialize();
  48.     return 0;
  49. }
  50.