5.1.1 IADsCollection

All collection objects support the COM interface IADsCollection. This interface is derived from IDispatch to make it a dual interface. The interface definition is as follows:

[ object, uuid(IID_IADsCollection), oleautomation, dual ]

interface IADsCollection: IDispatch

{

// Read-only properties.

[propget, restricted, id(-4)]

HRESULT _NewEnum([out, retval]Iunknown **ppEnumerator);

// Methods.

HRESULT Add([in]BSTRbstrName, VARIANT varItem);

// see implementation note, below

HRESULT Remove([in]BSTR bstrItemToBeRemoved)

HRESULT GetObject([in]bstrName,[out, retval]VARIANT *pvarItem);

// see implementation note, below

};

Method

Description

_NewEnum

Returns an enumerator dependent object that implements IEnumVARIANT. For more information, see "Enumerator Objects," later in this chapter.

Add

Adds the item varItem to the collection with the name bstrName. NOTE: the Add method applies only to collections supporting direct addition of new items. Collections that do not support direct addition of new items must return E_NOTIMPL if their Add method is called.

Remove

Removes the item specified by bstrItemToBeRemoved. The name provided to Remove is the name for the item as provided to by IADsCollection::Add for the item in question. NOTE: the Remove method applies only to collections supporting direct removal of items. Collections that do not support direct removal of items must return E_NOTIMPL if their Remove method is called..

GetObject

Returns the item specified by bstrName. The name provided to GetObject is the name for the object as provided to IADsCollection::Add for the item in question.