3.1.1 IDispatch

The IDispatch interface is defined by COM. It is the Automation interface for controllers that do not use COM interfaces directly. Accessing an object through IDispatch is called name-bound or late-bound access, since it occurs at run time ("late") and uses string names of properties and methods to resolve references ("name-bound").. At run-time, clients pass the string name of the property or method they wish to call into the IDispatch::GetIDsOfNames() method. If the property or method exists on the object, the client is returned the dispatch ID (dispID) of the corresponding function. The dispID can then be used to invoke the function using IDispatch::Invoke(). Using IDispatch, the properties and methods on the interfaces exposed by a single object appear as a flat list. Since name-bound access requires two function calls, it is less efficient than using a COM interface directly. Clients are encouraged to use the Active Directory COM interfaces on the objects when performance is a consideration. Advanced Automation Controllers such as Visual Basic 4.0 can call other COM interfaces as well as IDispatch, if the interfaces comply with Automation constraints for data types and parameter passing.

3.1.1.1 About Dispatch IDs

Active Directory providers generate dispatch Ids dynamically for each Active Directory object. The dispatch id's returned via GetIDsOfNames for a given object will be the generated values, not the values coded in the IDL for the object. IDispatch users must call GetIDsOFNames to obtain valid dispatch IDs at run time.