Description

Registers information necessary to instantiate an interface as a new McObjMgr type.

Return Type

A Long value.  

A new mcobjTypeEnum for the type. The type name will be the bstrTypeName.

Syntax

object.RegisterInterfaceClassFactory (bstrTypeName, varClassFactory, varInterfaceIID, [eControlFlags], [varBasetypeNameorEnum])

The RegisterInterfaceClassFactory Method syntax has these parts:

PartDescription
objectAn expression evaluating to an object of type McObjects.
bstrTypeNameRequired. A String value.

Name of the new type. This name must not conflict any other name in its namespace. Unless the name is supplied using the “::” syntax (e.g., “MyNamespace::MyTypeName”, the namespace used is the current default Namespace of this instance of the McObjects collection ("McOM" unless the Namespace property has been changed).

varClassFactoryRequired. A Variant value.

The class factory. This may be a VT_BSTR in which case the it must be the CLSID string of the CoClass in the form “{12345678-1234-1234-1234-123456789ABC}” or the ProgID (if the string does not start with a '{'). If it is a VT_UNKNOWN, then it is assumed to be the IClassFactory interface pointer itself.

varInterfaceIIDRequired. A Variant value.

The interface IID. This may be a VT_BSTR in which case the it must be the IID string of the form “{12345678-1234-1234-1234-123456789ABC}”. If it is a VT_UNKNOWN, then it is assumed to be an instance of the interface pointer itself; all objects Added of this type will have this interface as their data.

eControlFlagsOptional. A mcobjClassFactoryFlags enumeration, as described in settings.

mcobjClassFactoryFlags [in, defaultvalue(mcobjClassFactoryEachNew)] This optional flag controls whether multiple instances of the interface are created, or if the first created instance is to be used.

varBasetypeNameorEnumOptional. A Variant value.

If given, base type for the object. Can either be a BSTR typename or a long or short mcobjTypeEnum object type. If given, it must be a type derived from either mcobjTypeXOBJECT (the Type property will have the mcobjTypeFlagXOBJECT_Derived flag set) or mcobjTypeINTERFACE (the Type property will have the mcobjTypeFlagINTERFACE_Derived flag set). If this is missing, then then base type is determined by the eControlFlags mcobjClassFactoryIDispatch or mcobjClassFactoryIUnknown values (the default is mcobjClassFactoryIDispatch, which results in a base type of mcobjTypeXOBJECT).

Settings

The settings for eControlFlags are:

ConstantValueDescription
 mcobjClassFactoryDefault0

Default flags.

 mcobjClassFactoryEachNew0

(The default) Each firing of the Class Factory creates a new instance of the interface .

 mcobjClassFactoryOnceOnly1

Only one instance of the interface is created; subsequent firings of the Class Factory use the existing instance. The original instance is not Released until the class factory is unregistered.

 mcobjClassFactoryIDispatch0

(The default) The IID for the Class Factory is an interface derived from IDispatch; that is, it is either a dispinterface or a dual interface. The registered Object type is derived from mcobjTypeXOBJECT, and the Value of such an McObject will be of type VT_DISPATCH.

 mcobjClassFactoryIUnknown2

The IID for the Class Factory may be a custom interface. The registered Object type is derived from mcobjTypeINTERFACE, and the Value of such an McObject will be of type VT_UNKNOWN.

Remarks

Once registered, an McObject of this interface type created by the McObjects.Add method will have as its Value an IInterface* which implements the interface. The McObject.Interface property will allow you to access this interface. Use the UnregisterType method to unregister a type.

You cannot UnregisterType any registered class factory for which any objects of that type still exist.