Inheritance diagram for IEventBase:
Since the event handling model is different in scripting than in other languages such as for instance C++ and VB, an interface has been added to allow scripting users to handle events more easily. This interface contains 2 methods, one to attach to an event and one to detach from an event.
Attaching to an event is done using the following method: when an event fires, let the API call a specific method/sub/function in a script. After detaching an event, the API will not call the method/sub/function in the script anymore.
To attach, use AttachEvent. Detach using DetachEvent.
See the detailed sections of the methods/properties for more information.
Public Member Functions | |
HRESULT | AttachEvent ([in] VARIANT vtEvent,[in] VARIANT vtFunctionPointer,[out, retval] VARIANT_BOOL *pfSucceeded) |
Attach an event to a function or sub. | |
HRESULT | DetachEvent ([in] VARIANT vtEvent,[in] VARIANT vtFunctionPointer,[out, retval] VARIANT_BOOL *pfSucceeded) |
Detach an event from a function/sub. |
|
Attach an event to a function or sub. Use this method to subscribe/attach to an event on this object. Whenever the event fires on this object the supplied function will be called. In VBScript, use the "GetRef" to get a pointer to a function. In JScript, the function can be passed directly into the vtFunctionPointer argument. The following example shows how to attach to a OnProcessStarted event of the application object in VBScript:
Sub OnProcessInfo(ProcessType, objBase, SubProcessType, Info) If SubProcessType = 4 Then ' 4 indicates the sptItemFound sub process MsgBox "Found a new network on port " & Info End If End Sub Dim objApp Set objApp = CreateObject("TalosAPI.Application") ' Attach the event objApp.AttachEvent 0x03, GetRef("OnProcessInfo") ' 0x01 is the ID of the OnProcessInfo event ' Execute the scan objApp.ScanReaderNetworks When the each found network, the 'OnProcessInfo' method will now be called, showing a messagebox with the port number (= default property) of the found network.
|
|
Detach an event from a function/sub. Detach from an event. This method should be called when you do not want to receive events from a specific object anymore.
|