次の方法で共有


IADsCollection::Remove メソッド (iads.h)

IADsCollection::Remove メソッドは、この ADSI コレクション オブジェクトから名前付き項目を削除します。

構文

HRESULT Remove(
  [in] BSTR bstrItemToBeRemoved
);

パラメーター

[in] bstrItemToBeRemoved

IADsCollection::Add で指定されたアイテムの名前を指定する null で終わる Unicode 文字列。

戻り値

このメソッドは、S_OKを含む標準の戻り値 サポートします。 詳細およびその他の戻り値については、「 ADSI エラー コード」を参照してください。

解説

ディレクトリ サービスのコレクションは、変更できないオブジェクトのセットで構成することもできます。

E_NOTIMPL を返すには、アイテムの直接削除をサポートしていないコレクションが必要です。

次の Visual Basic コード例は、アクティブなファイル サービス セッションのコレクションから名前付きセッション オブジェクトを削除する方法を示しています。

Dim fso As IADsFileServiceOperations 
Dim ses As IADsSession
Dim coll As IADsCollection
Dim mySessionName As String

On Error GoTo Cleanup

Set fso = GetObject("WinNT://myComputer/FabrikamServer") 
Set coll = fso.Sessions

' Insert code to set mySessionName to the name of the mySession 
' session object.
 
' The following statement invokes IADsCollection::Remove.
coll.Remove mySessionName

Cleanup:
    If (Err.Number<>0) Then
        MsgBox("An error has occurred. " & Err.Number)
    End If
    Set fso = Nothing
    Set ses = Nothing
    Set coll = Nothing

次の C++ コード例は、アクティブなファイル サービス セッションのコレクションから名前付きセッション オブジェクトを削除する方法を示しています。

HRESULT RemoveASessionObjectFromCollection()
{
    LPWSTR adspath = L"WinNT://myComputer/FabrikamServer";
    HRESULT hr = S_OK;
    IADsCollection *pColl = NULL;
    IADsFileServiceOperations *pFso = NULL;

    hr = ADsGetObject(adspath,IID_IADsFileServiceOperations,(void**)&pFso);
    if(FAILED(hr)) {goto Cleanup;}

    hr = pFso->Sessions(&pColl);
    if(FAILED(hr)) {goto Cleanup;}

    hr = pColl->Remove(CComBSTR("MySession"));

Cleanup
    if(pFso) pFso->Release();
    if(pColl) pColl->Release();

    return hr;
}

要件

   
サポートされている最小のクライアント Windows Vista
サポートされている最小のサーバー Windows Server 2008
対象プラットフォーム Windows
ヘッダー iads.h
[DLL] Activeds.dll

関連項目

ADSI エラー コード

IADsCollection

IADsCollection::Add