ImportTypeLib Documentation

Usage Information - Classes

COM classes (so-called coclasses) are wrapped by ImportTypeLib. They are mainly used in conjunction with interfaces.

Creating an instance

Creating and instance of a class is the most common thing to do with it.
ptr := ITL_CoClassWrapper.__New([IID])
This form is not directly used by a script, Instead, the new operator can be used:
lib := ImportTypeLib("C:\Path\To\MyLib.tlb")
ptr := new lib.MyClass()

Parameter

IID In the form showed above, without parameters, a new class instance is created for the default interface of the coclass. If no such default exists, an exception is thrown. To prevent that or to use another than the default interface, an IID may be given. If the interface is part of the type library itself, the IID may be obtained and used like so:
IID_IMyInterface := lib.GetGUID("IMyInterface") ; gets the IID of the interface from the type library
instance := new lib.MyClass(IID_IMyInterface)

Returns

The returned ptr is not an object, but a pointer. This pointer can be enwrapped with the corresponding interface instance like so:
obj := new lib.IMyInterface(ptr)

Throws

If no IID is given and there's no default either, if the specified IID is not registered within the system, or if any other error occurs, an exception is thrown.

Constants and static variables

Those are not (yet) supported in a class.