Platform SDK: Active Directory, ADSI, and Directory Services |
A dual interface allows direct vtable access to all its functions while a dispatch interface does not. A C/C++ client can query for a dual interface pointer and use direct vtable access to invoke its functions. This provides faster access than invoking the function using the IDispatch::GetIDsOfNames and IDispatch::Invoke functions. This is especially true in our extension model, since all dual interfaces in an extension object must delegate their GetIDsOfNames and Invoke functions back to the aggregator (ADSI) first. The aggregator then needs to perform extra internal steps to sort out which extension object (possibly including the aggregator itself) provides support for the function being called and redirect the call to the appropriate object.
Visual Basic also invokes a dual-interface function using direct access to a vtable, if it has a pointer to the interface and access to type information from the type library. ADSI clients written in Visual Basic can specify a pointer to a dual interface, for example, IADsDualInf, explicitly, and thus enable vtable access to functions in the interface.
Dim inf as IADsDualInf Set inf = GetObject(…) 'An object supporting IADsDualInf. inf.Func1 'IADsDaulInf::Func1() will be invoked through 'Direct vtable access.
Since an IDispatch interface does not support vtable access, this example does not apply. In other words, a dispatch function is always invoked through the IDispatch::GetIDsOfNames and IDispatch::Invoke functions only.
Current releases of VBScript and JavaScript also do not support vtable access. Therefore, a dual interface in a VBScript or JavaScript environment behaves like a dispatch interface.