Description

Implements the standard collection “Item” method for one category and some particular (or no) parent object.

Return Type

A McObject object.  

The McObject (S_OK is returned from the method call) or Nothing if the specified item was not found (S_FALSE returned from the method). Use “Is Nothing” from VB to test the returned object.

Syntax

object.GetCategoryItem (varCategoryNameOrID, bstrName, [varParentIMcObject], [bstrNamespace], [eLookupMethods])

The GetCategoryItem Method syntax has these parts:

PartDescription
objectAn expression evaluating to an object of type McObjects.
varCategoryNameOrIDRequired. A Variant value.

Category name or ID (as returned from RegisterCategory). This may be VT_EMTPY or zero, to indicate objects not part of any category.

bstrNameRequired. A String value.

Name of the McObject sought. The name may have “dot” syntax if the item is a child of some other object and it may use the "double colon" syntax for namespaces. Any “double colon” syntax will override the effect of the bstrNamespace and eLookupMethods arguments (below). If a namespace is specified by the “double colon” syntax then it must match exactly. If a parent is specified without a “Namespace::”, then it is looked up using the same namespace rules as for the target name (see below).

varParentIMcObjectOptional. A Variant value.

VARIANT [in, optional] The parent object, or if missing (VT_EMTPY, VT_ERROR or VT_NULL) or a NULL pointer, then only an object with no parent is found.

bstrNamespaceOptional. A String value.

is supplied, then the default lookup method is mcobjMatchExactNamespace.

eLookupMethodsOptional. A mcobjNamespaceMatchMethods enumeration, as described in settings.

mcobjNamespaceMatchMethods [in, defaultvalue(mcobjMatchMethodDefault)] The default behavior (0) differs depending on whether bstrNamespace is given or not. If no bstrNamespace argument is supplied, then the mcobjMatchScopedNamespace method is used with the default Namespace property as the target namespace. If a particular

Settings

The settings for eLookupMethods are:

ConstantValueDescription
 mcobjMatchMethodDefault0

Default match method. This varies depending on whether an explicit namespace argument is supplied. For Item lookups, or for the SetEnumFilter or GetCategory_NewEnum methods, if no bstrNamespace argument is supplied (i.e, it is NULL or empty), then the mcobjMatchScopedNamespace method is used with the default Namespace property as the target namespace. If a particular target bstrNamespace is supplied, then the default lookup method is mcobjMatchExactNamespace.

 mcobjMatchExactNamespace4096

The target namespace must match the object's namespace exactly.

 mcobjMatchScopedNamespace8192

The object's namespace needs to match the target only up to the length of the the stored object namespace string. However, if there are multiple such objects, the one with the longest namespace string is returned as the matching entry. Example: target namespace "ABC::": objects with namespaces “ABC::”, “AB::”, “A::” or “::” match in that order of precedence. Objects with namespaces “ABCD::”, “ABX::”, and so on do NOT match.

 mcobjMatchAtLeastNamespace12288

The object's namespace must match the target namespace only up to the length of the target namespace (which can be empty for lookups with any namespace). If more than one matches, then the one with the shortest namespace (i.e, the most “global”) matching up to the length of the target is prefered (or the first one if there is a tie). This lookup can be used when you have some name and a namespace and you wish to find some object of that name which is within the namespace or a deeper one. Example: given a target namespace of "ABC::": objects with namespace “ABC::”, “ABCD::”, “ABCDE::” and "ABCE::"all match, in that order of precedence. Objects with namespace “AB::”, “A::”, “XYZ::”, and so on do NOT match.

 mcobjMatchMethodIgnoreNamespace16384

The object's namespace is ignored in the test. For Item lookup's, this is equivalent to specifying a global ("::") target namespace with the mcobjMatchAtLeastNamespace lookup method. For SetEnumFilter or GetEnum methods, no namespace filter is applied, so objects with any namespace are enumerated, so long as they pass the other tests.

 mcobjNamespaceMatchMethodsMask28672

A mask for these values.

Remarks

Items must be specified by name and their parent object, if any. The A Namespace to use for the name lookup can be specified and several methods can be specified for its use. If a requested name with the specified parent is not found in the category, then a search is made for an “Auto Add” with the requested name and namespace, which was previously attached to the requested category by AttachAutoAddToCategory. If a name match is found and the parent object is compatible with the type specified in the AttachAutoAddToCategory call, then an McObject instance is automatically created.