tlbimp.jar comes with an implementation of Apache Ant task so that you can integrate tlbimp into your build process easily.
To declare the tlbimp task, include the following statement in your build script:
The tlbimp task supports the following attributes.
|destdir||The output directory in which all the generated files will be placed. The package name will be automatically appended to this directory.||Yes|
|package||The default Java package name in which the generated types will be placed (unless overriden by <lib @package="..." />)||No. Defaults to ""|
|locale||The locale to be used to convert method names and others. This is a string like "en_US", "ja_JP", etc.||No. Defaults to the system default locale|
A <lib> element specifies one type library to compile. Sometimes a type library depends on other type libraries. Multiple lib elements can be used in this situation to control where each of the referenced type libraries are generated.
This element can take the following attributes:
|file||A file that contains the type library to be processed.||One of two.|
|libid||The LIBID of the type library to be processed. A string of the form "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"|
|libver||The version of the type library given by @libid to be processed. When omitted, tlbimp searches the latest version and process it. A string of the form "major.minor"||No. only valid with @libid|
@libid and @libver needs more explanation. Often, the location of type libraries vary from a system to system. For example, the type library for Microsoft Office is installed in the same directory where the user installed Microsoft Office. Because people install things in different places, when multiple people are working on the same project, this makes it difficult to consistently refer to the same type library.
@libid and @libver are useful in this case. Each type library has a unique GUID called "LIBID", and the version of the type library. For example, Microsoft Excel 2000 type library has the LIBID of "00020813-0000-0000-C000-000000000046" and the version of "1.3". Together they allow you to reference a type library without knowing its actual location on the disk.
To find out the LIBID, the library version, and its dependencies, use OleView.
Compile Microsoft Excel type library without refering to the file path.
Compile Microsoft PowerPoint type library and its dependencies.