Navigation:  Programming Cookbook > Creating COM Components > Building a COM component >

Generate Interfaces

Previous pageReturn to chapter overviewNext page

Once you have a type-library available, or a component with a type-library bound into it, you can use the Active-X Component Wizard to automatically generate wrapper classes for all the interfaces and structures defined in the type-library. The first time you run the wizard your library will not be in the initial list, and you will have to browse the list of registered components for it. If you have just built the library, then it will not be in that list either, and it will be necessary to browse for and open the DLL, OCX, or type-library (TLB) file.

Once the library is in the list on the first page of the wizard, step through to the second page and enter the package name and prefix you’d like to prepended to generated class names. For the random stream sample move to the last page, select everything with Ctrl+A, and press the Generate button. You can now browser the generated class(es) by selecting one of the entries in the type list and choosing the Browse Class command from the context menu.

If the generated methods do not seem to match what you would expect, try viewing the reverse engineered IDL by using the Browse IDL command on context menu’s of the library list (step 1) or type list (step 3). The reverse engineered IDL may not match your input IDL because not all of the information in the source IDL is correctly translated and/or preserved by the type-library output of MIDL. It is unlikely that this will be the case, but when it happens you may have to revise your IDL. Alternatively the IDL may not match at all because you are picking up an old copy of the type-library – something we find to be a common occurrence. Try browsing the file system for the type library and opening it again..

If you are running a standard Dolphin installation then the Random Stream sample interface will already have been generated from the type-library. Nevertheless you might like to run through the wizard and generate it again. When first generating interface wrappers we recommend sticking with the default settings, but you might like to try regenerating the IRandomStream with different settings to see the effects.

Tip: Make sure that any generated methods that you modify, or new methods that you add, are removed from the ** auto generated ** category, as this will be deleted when the interface is regenerated, losing any changes or additions you might have made.