Kim Gräsman, 2003
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.
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) |
| -pm | Use module name as prefix (optional) |
| -pe | Use enum name as prefix (optional |
| -d | Disable alias name resolving (default: false) |
| -a | Generate ASP tags in output (default: false) |
| -h | Emit 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.
2003-10-29
Remon Spekreijse suggested a couple of nice features:
2002-11-19
2001-12-15
First public release
I'd really like to hear about any bugs or missing features.
tlb2const.zip (32 KB)