Using the Module Wizard to Generate Code

To run the Visual Fortran Module Wizard, choose the Tools menu item Fortran Module Wizard. The module wizard asks a series of questions, including the name and type of the object as well as certain characteristics. If you have not already obtained the object's characteristics, see The Role of the Module Wizard.

The Visual Fortran Module Wizard presents a series of dialog boxes that allow you to select the type of information needed.

An object's type information contains programming language independent descriptions of the object's interfaces. Depending on the implementation of the object, type information can be obtained from the running object (see Automation Object below) or from a type library.

A type library is a collection of type information for any number of object classes, interfaces, and so on. A type library can also be used to describe the routines in a DLL. You can store a type library in a file of its own (usually with an extension of .TLB) or it can be part of another file. For example, the type library that describes a DLL can be stored in the DLL itself.

After you start the Module Wizard (Tools menu, Fortran Module Wizard), a dialog box requests the source of the type information that describes the object you need to use. You need to determine what type of object it is (or DLL) and how it makes its type information available. The choices are:

Object servers typically contain the type library in the same file (either .dll or .exe) as the object implementation.

Many objects implement dual interfaces, which supports both COM and Automation. For an object that supports dual interfaces, you can choose either of these options:

The COM object interfaces tend to be more efficient (better run-time performance).

ActiveX controls implement an Automation interface. When using an ActiveX control, choose the Type Library containing Automation interface information option.

Most DLLs do not provide a type library that describes the programming interfaces in the DLL, and therefore cannot be used by the Module Wizard.

For these reasons, the Automation Information (second option) or COM Interface Information (third option) are the most commonly used.

The following initial screen appears after you select the Visual Fortran Module Wizard:

Initial Module Wizard Screen

initial module wizard screen

After you select one of the five choices, one of two different screens will appear depending on the selection made. The "Module Name" in the initial Module Wizard screen is used as the name of the Fortran module being generated. It is also used as the default file name of the generated source file.

If You Select Automation Object

If you select Automation Object, the following screen appears:

Application Object Screen

application object screen

Microsoft recommends that object servers provide a type library. However some applications do not, but do provide type information dynamically when running. Use this option for such an application. Enter the name of the application, name of the object, and version number. The version number is optional. If you do not specify it, you will get the latest version of the object. Note that this method only works for objects that provide a programmatic identifier (ProgID). ProgIDs are entered into the system registry and identify, among other things, the executable program that is the object's server.

After entering the information and pressing the Generate button, the Fortran Module Wizard asks you for the name of the source file to be generated. It then asks COM to create an instance of the object identified by the ProgID that the wizard constructs using the supplied information. COM starts the object's server if it needs to do so. The wizard then asks the object for its type information and generates a file containing Fortran modules.

If You Select Other Options

After selecting any of the remaining options in the initial screen and press the "Next" button, the Module Wizard displays the following screen:

Type Library Screen

type library screen

Choose the type library (or file containing the type library), and optionally specific components of the type library.

At the top of the dialog box is a combo box that lists all of the type libraries that have been registered with the system. You will notice a number of different file extensions, for example, .OLB (object libraries) and .OCX (ActiveX controls). Select a type library from the list or press Browse to find the file using the standard "Open" dialog box. Once you have selected a type library press the Show button to list the components you can select from the type library. By default, the Fortran Module Wizard will use all of the components. Optionally, you can select the ones desired from the list.

After entering the information and pressing the "Generate" button, the Fortran Module Wizard asks you for the name of the source file to be generated. It then asks COM to open the type library and generates a file containing Fortran modules.

The Fortran Module Wizard also has a command-line interface. The MODWIZ command has the following form:

MODWIZ [options] typeinfo-name

For a list of MODWIZ command options and an explanation of typeinfo-name, type the following command in a Fortran Command Prompt (available from the Visual Fortran program folder):

   MODWIZ /?