tlb2const v.1.2

Kim Gräsman, 2003

Background

If you're developing COM components aimed at script developers, there really is no way of exposing constants. Enumerations and constants are built into the type library, but since script languages don't necessarily read type libraries, we're back to square one. In all fairness, many script hosts (including ASP and WScript) read typelibraries, extracting such information, but I prefer pre-generated constants for a good overview.

tlb2const is supposed to be a build-time bridge between typelibs and scripting.

Usage

tlb2const generates a script file containing constants from a type library with enum declarations.

Running tlb2const without arguments shows a brief usage description:

-i:<filename>Input filename (type library)
-o:<filename>Output filename (Script file)
-l:<language>Script output language (Currently supported: vbs, js)
-p:<prefix>Prefix appended to every constant (optional)
-pmUse module name as prefix (optional)
-peUse enum name as prefix (optional
-dDisable alias name resolving (default: false)
-aGenerate ASP tags in output (default: false)
-hEmit constants in hex (default: false)
-w:<nn>Pad constant names to width nn
-z:<nn>Zero-pad values to nn significant digits (requires -h)

Note that if -l: is not provided, the language is resolved from the output script file extension (.js or .vbs).

The command-line nature of tlb2const makes it suitable for automated builds.

Version history

Version 1.2

2003-10-29

Remon Spekreijse suggested a couple of nice features:

and I couldn't help myself from making the following changes:

Version 1.1

2002-11-19

Version 1.0

2001-12-15

First public release

Feedback

I'd really like to hear about any bugs or missing features.

Downloads

tlb2const.zip (32 KB)