共用方式為


3.1.4.6.5 Add (Opnum 11)

The Add method adds an item to the underlying collection of the enumerator; if the item is already present in the collection, it is replaced by the one being passed to this method.

 [id(3), helpstring("Add an item to the collection")] HRESULT Add(
   [in] VARIANT* item,
   [in] BSTR objectID
 );

item: If the underlying collection is of application-specific publisher/subscriber subscription properties, this MUST conform to the application-specific property values as specified in section 2.2.2.2. If the underlying collection is of event classes, the type of the VARIANT MUST be VT_UNKNOWN and MUST contain a DCOM object supporting the IEventClass2 interface. If the underlying collection is of subscriptions, the type of the VARIANT MUST be VT_UNKNOWN and MUST contain a DCOM object supporting the IEventSubscription interface.

objectID: The identity of the object. If the underlying collection is of the application-specific publisher/subscriber subscription properties, this MUST conform to the application-specific property names as specified in 2.2.2.1. If the underlying collection is of event classes, this MUST conform to the EventClassID property of the event class as specified in section 3.1.1.1. If the underlying collection is of subscriptions, this MUST conform to the SubscriptionID property of the subscription as specified in section 3.1.1.2.

Return Values: An HRESULT specifying success or failure. All success codes MUST be treated the same, and all failure codes MUST be treated the same.

When this method is invoked, the server MUST validate the item and the objectID parameters. If the validation fails, the server MUST fail the call, returning a failure HRESULT back to the client. Otherwise, the server MUST attempt to add this item to the collection of the enumerator DCOM object servicing this call, and fail the call if it cannot. If the object in the collection already has the objectID specified in the call, the server MUST fail the call.