Description

Removes an McObject from the collection.

Return Type

A Long value.  

The remaining reference count on the referenced object. If this is zero, then the object will have been deleted, and pimcobjectToRemove will no longer be a valid pointer. If it is 1, then any subsequent single Release will delete the object.

Syntax

object.Remove (pimcobjectToRemove, [vbKillObject])

The Remove Method syntax has these parts:

PartDescription
objectAn expression evaluating to an object of type McObjects.
pimcobjectToRemoveRequired. An Unknown object.

The McObject* of the McObject to remove from the collection.

vbKillObject=TRUE : [in,defaultvalue(TRUE)] If FALSE, the McObject and any children removed from the collection will be left functional. If TRUE (the default), then all data held by the McObject and any children are freed, thus rendering these objects unusable (i.e., killing them).

vbKillObjectOptional. A Boolean value.

Remarks

The McObject is removed from the McObjects collection and it is Released, but it is only actually deleted if the object's reference count reaches zero. If the object is the Parent for any “child” McObjects, then they are also automatically removed from the collection.

Quite often a call to this method will not delete the refered to object immediately, since the calling application will have bumped the reference count on the *pimcobjectToRemove. You may not be aware of this AddRef, if you are using pointer wrapper classes (e.g., the C++ _com_ptr_t class) or some high level client language such as VB, since the AddRef and Release can happen automatically.

However, after this call unless you have set the vbKillObject argument FALSE, the object and any children are non-functional and none of their methods or properties may be accessed. Any such access will result in an "Invalid Handle" error. And in any case, the object will no longer appear in any McObjects enumeration (e.g., a “for each” statement).

Once an object has been removed from the collection, there is no mechanism for putting it back in.