CORE.CPP
上传用户:bangxh
上传日期:2007-01-31
资源大小:42235k
文件大小:3k
源码类别:

Windows编程

开发平台:

Visual C++

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4.     Core.cpp
  5. Abstract:
  6.     CCoreADsObject - Implementation
  7. Author:
  8. Environment:
  9.     User mode
  10. Revision History :
  11. --*/
  12. #include "adssmp.h"
  13. #pragma hdrstop
  14. HRESULT
  15. CCoreADsObject::InitializeCoreObject(
  16.         BSTR Parent,
  17.         BSTR Name,
  18.         BSTR ClassName,
  19.         BSTR Schema,
  20.         REFCLSID rclsid,
  21.         DWORD dwObjectState
  22.         )
  23. {
  24.     HRESULT hr = S_OK;
  25.     ADsAssert(Parent);
  26.     ADsAssert(Name);
  27.     ADsAssert(ClassName);
  28.     hr = BuildADsPath(
  29.             Parent,
  30.             Name,
  31.             &_ADsPath
  32.             );
  33.     BAIL_ON_FAILURE(hr);
  34.     hr = BuildADsGuid(
  35.             rclsid,
  36.             &_ADsGuid
  37.             );
  38.     BAIL_ON_FAILURE(hr);
  39.     hr = xx_put_BSTR(&_Parent, Parent);
  40.     BAIL_ON_FAILURE(hr);
  41.     hr = xx_put_BSTR(&_Name, Name);
  42.     BAIL_ON_FAILURE(hr);
  43.     hr = xx_put_BSTR(&_ADsClass, ClassName);
  44.     BAIL_ON_FAILURE(hr);
  45.     hr = BuildSchemaPath(
  46.             _ADsPath,
  47.             ClassName,
  48.             &_Schema
  49.             );
  50.     BAIL_ON_FAILURE(hr);
  51.     
  52.     _dwObjectState = dwObjectState;
  53. error:
  54.     RRETURN(hr);
  55. }
  56. CCoreADsObject::CCoreADsObject():
  57.                         _Name(NULL),
  58.                         _ADsPath(NULL),
  59.                         _Parent(NULL),
  60.                         _ADsClass(NULL),
  61.                         _Schema(NULL),
  62.                         _ADsGuid(NULL),
  63.                         _dwObjectState(0)
  64. {
  65. }
  66. CCoreADsObject::~CCoreADsObject()
  67. {
  68.     if (_Name) {
  69.         ProvFreeString(_Name);
  70.     }
  71.     if (_ADsPath) {
  72.         ProvFreeString(_ADsPath);
  73.     }
  74.     if (_Parent) {
  75.         ProvFreeString(_Parent);
  76.     }
  77.     if (_ADsClass) {
  78.         ProvFreeString(_ADsClass);
  79.     }
  80.     if (_Schema) {
  81.         ProvFreeString(_Schema);
  82.     }
  83.     if (_ADsGuid) {
  84.         ProvFreeString(_ADsGuid);
  85.     }
  86. }
  87. HRESULT
  88. CCoreADsObject::get_CoreName(BSTR * retval)
  89. {
  90.     HRESULT hr;
  91.     if (FAILED(hr = ValidateOutParameter(retval))){
  92.         RRETURN(hr);
  93.     }
  94.     RRETURN(ProvAllocString(_Name, retval));
  95. }
  96. HRESULT
  97. CCoreADsObject::get_CoreADsPath(BSTR * retval)
  98. {
  99.     HRESULT hr;
  100.     if (FAILED(hr = ValidateOutParameter(retval))){
  101.         RRETURN(hr);
  102.     }
  103.     RRETURN(ProvAllocString(_ADsPath, retval));
  104. }
  105. HRESULT
  106. CCoreADsObject::get_CoreADsClass(BSTR * retval)
  107. {
  108.     HRESULT hr;
  109.     if (FAILED(hr = ValidateOutParameter(retval))){
  110.         RRETURN(hr);
  111.     }
  112.     RRETURN(ProvAllocString(_ADsClass, retval));
  113. }
  114. HRESULT
  115. CCoreADsObject::get_CoreParent(BSTR * retval)
  116. {
  117.     HRESULT hr;
  118.     if (FAILED(hr = ValidateOutParameter(retval))){
  119.         RRETURN(hr);
  120.     }
  121.     RRETURN(ProvAllocString(_Parent, retval));
  122. }
  123. HRESULT
  124. CCoreADsObject::get_CoreSchema(BSTR * retval)
  125. {
  126.     HRESULT hr;
  127.     if (FAILED(hr = ValidateOutParameter(retval))){
  128.         RRETURN(hr);
  129.     }
  130.     if ( _Schema == NULL || *_Schema == 0 )
  131.         RRETURN(E_ADS_PROPERTY_NOT_SUPPORTED);
  132.     RRETURN(ProvAllocString(_Schema, retval));
  133. }
  134. HRESULT
  135. CCoreADsObject::get_CoreGUID(BSTR * retval)
  136. {
  137.     HRESULT hr;
  138.     if (FAILED(hr = ValidateOutParameter(retval))){
  139.         RRETURN(hr);
  140.     }
  141.     RRETURN(ProvAllocString(_ADsGuid, retval));
  142. }
  143. STDMETHODIMP
  144. CCoreADsObject::GetInfo(
  145.     BOOL fExplicit
  146.     )
  147. {
  148.     RRETURN(E_NOTIMPL);
  149. }