Microsoft® Windows® Script Host ConnectObject Method |
WSH Reference Version 2 |
Connects an object's event sources to functions with a given prefix.
object.ConnectObject strObject, strPrefix
Part Description object WScript object. strObject Name of the object to be connected. strPrefix Prefix of the event function.
The object must be capable of enumerating its own class event set.
The following example instantiates a fictitious object and connects it to the script file. The script then calls the "SomeMethod" method on the object. If an event called "Event" occurs in the object, the MyEvent_Event subroutine is called.Set MyObject = WScript.CreateObject("SomeObject") MyObject.SomeMethod WScript.ConnectObject MyObject, "MyEvent" Sub MyEvent_Event(strName) WScript.Echo strName End Sub WScript.DisconnectObject MyObject