Home | Overview | How Do I | Sample | Tutorial
Automation clients must have information about server objects’ properties and methods if the clients are to manipulate the servers’ objects. Properties have data types; methods often return values and accept parameters. The client requires information about the data types of all of these in order to statically bind to the server object type.
This type information can be made known in several ways. The recommended way is to create a type library.
For information on Microsoft Object Description Language (ODL) and MkTypLib, see the OLE Programmer's Reference in the Win32 SDK.
ClassWizard can read a type-library file and create a dispatch class derived from COleDispatchDriver. An object of that class has properties and operations duplicating those of the server object. Your application calls this object’s properties and operations, and functionality inherited from COleDispatchDriver routes these calls to the OLE system, which in turn routes them to the server object.
ClassWizard automatically maintains this type-library file for you if you chose to include Automation when the project was created. As part of each build, the .tlb file will be built with MkTypLib.
To create a dispatch class from a type-library (.tlb) file
The Add Class menu appears.
An Import from Type Library dialog box appears.
Tip Some type library information is stored in files with .DLL, .OCX, or .OLB file extensions.
The Confirm Classes dialog box appears. The list contains the external names of the classes described in the type-library file. Other controls in the Confirm Classes dialog box show the proposed names for the dispatch classes and for the header and implementation files for those classes. As you select a class in the list box, the Class Name box shows the name for the corresponding class.
You can use the Browse buttons to select other files, if you prefer to have the header and implementation information written in existing files or in a directory other than the project directory.
The Type Library Tool writes header and implementation code for your dispatch class, using the class names and file names you have supplied, and adds the .CPP file to your project.
See Also ClassWizard: Adding Automation Properties and Methods