Ekas Software Windows Script Host Control for Delphi Help
Adding Delphi objects to script
Quick start: common questions
Any instance of class which descends from TPersistent can be added to script environment using TekWSHControl.RegisterClass method. It has 2 parameters:

const Name: string - defines the name which will represent object in script. Please note that all objects in script environment must have unique names, so it is programmer's responsibility to ensure that there is no other object with choosen name already existing in the script. Exception will be thrown in other case.

AClass: TPersistent - the instance itself.

TekWSHControl creates proxy object implementing IDispatch interface for given object and adds it to script. So, script operates not with object itself but with its proxy object to avoid automatic destroying of object after script executing (because of object represented in script as IDispatch interface anyway, and all refences are released after script is finished and so object is destroyed).

As said above, proxy object implements IDispatch inteface (especially, GetIdsOfNames and Invoke methods) to provide object's properties reading and writing and methods calling. It operates with RTTI information and so only published members of objects can be operated in script.

Also, it is very important to register object's class within Delphi application using Classes.RegisterClass procedure to be shure that RTTI presents (Delphi compiler exludes it from resulting code due to optimization, if class does not registered obviously).


Ekas Software Windows Script Host Control for Delphi Help
Copyright (c)2002,2003 Ekas Software