The information in this article applies to:
SUMMARYCollect.exe demonstrates how to create an OLE automation collection object. MORE INFORMATIONThe following file is available for download from the Microsoft
Download Center. Click the file name below to download the file: Collect.exeFor more information about how to download files from the Microsoft Download Center, please visit the Download Center at the following Web address http://www.microsoft.com/downloads/search.aspand then click How to use the Microsoft Download Center. The collection object implements the following methods and properties: Add Method, Count Property, Item Property, NewEnum Property, and Remove Method. Error handling in the collection object involves raising exceptions. CreateStdDispatch does not allow exceptions to be raised, so the collection object implements the IDispatch interface using DispGetIDsOfNames and DispInvoke. Add Method NOTE: The Add method is not appropriate for all collections, so it is not
required. For many application-created collections, objects are
automatically added to the collection for the user.
Count Property
Item Property NOTE: Item is the default value for the object, so it should have the
special DISPID, DISPID_VALUE. MkTypLib automatically assigns this DISPID if
the default attribute is specified in the ODL file.
_NewEnum Property NOTE: NewEnum will not be accessible to users and must have the restricted
attribute in the ODL file. The NewEnum method must have a special DISPID,
DISPID_NEWENUM. The defining characteristic of a collection is the ability
for a user to iterate over the items in it. Some languages will have built-
in support for collections. The NewEnum method allows an OLE automation
controller to support "for each" iteration over a collection:
OLE automation controllers that support "for each" iteration will call the
NewEnum method on the collection object and then QueryInterface on the
resulting IUnknown to get the desired IEnumVariant.
Remove Method NOTE: The object is not deleted. It is simply removed from the collection.
Remove should support the same kinds of indexing as the Item() method for
the same collection. The Remove method is not appropriate for all
collections, so it is not required. For many application-created
collections, objects are automatically removed the collection for the user.
To RunThe collection sample application object exposes the following:
Update the path in HELLO.REG to the current location of the object and the
type libraries.
To CompileRequires OLE version 2.01 or later.Include device=vmb.386 in the [386Enh] section of SYSTEM.INI. NOTE: vmb.386 can be found in \OLE2\BIN. Run WXSERVER.EXE from \OLE2\BIN before running the makefile. Additional query words:
Keywords : kbfile kbsample kbAutomation kbNTOS350 kbNTOS351 kbOLE200 kbWinOS95 kbGrpCom kbDSupport |
Last Reviewed: December 7, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |