We have customers asking for VBScript functions to be called when particular actions occur within our product. I\'ve been trying to research the Windows Scripting technologi
IActiveScript
and related interfaces work very well. I use them in my product exactly the same way you have described. Some of out customers write their own VBScript and JScript scripts to analyze and update application data before it gets posted to a database.
You use CoCreateInstance()
to instantiate IActiveScript
, like you would any other COM object. You would then call its QueryInterface()
method to obtain an IActiveScriptParse
interface for loading snippets of scripting code, and then you update the IActiveScript
's state to execute the code.
You can add custom objects to the script by implementing IDispatch
-derived classes and then passing them to the engine using IActiveScript::AddNamedItem()
and an IActiveScriptSite::GetItemInfo()
callback.
There are examples of IActiveScript
usage available on MSDN.