This one and Connect methods are recommended only to the experienced programmers with
deep COM knowledge. Script engines have different requirements to the items in order to
sink their events. Additionally threading is important in that case you must take care
about the thread that fires the events (see MSDN for some notes).
JScript requires items (or subitems) to support at least IProvideClassInfo
interface in order to obtain event dispinterface information. JScript engine also checks
for IDispatchEx thus one of these two interfaces will be enough if you are implenting the
component that will fire events to the script
VBScript requires items (or subitems) to support IDispatchEx interface. Thus
VBScript is much more problematic if you want to save some work when developing components
for use with VB scripting.
What means subitem? Typically subitem is the name of the property that returns
IDispatch (or packed in the VARIANT IUbknown or IDispatch) of the another object.
Event name is the name of the method of the event dispininterface of the item (or
subitem). Arguments of the event are passed as arguments of the internally generated by
the script engine function (see below).
Code added must not contain head or footer of the function/subroutine declaration.
Script engine generates function and uses this code as a body. For example in JScript if
the item is MyItem and event is MyEvent (without parameters) function
declaration will be:
function MyItem::MyEvent() {
// code
}
In VBScript this will be:
Sub MyItem_MyEvent
' code
End Sub
You must care about the names of the items and events because their names form the
function/subroutine declaration thus if their names are valid for the automation but not
valid for the particular script language syntax - error will be genrated.