After deeply studying the code and headers generated by TLIBIMP, this is pretty easy.
If your type library has the Foo class, then after importing the type library you usually use classes with automatic creation of smart IFooPtr pointers.
{ IFooPtr f; ... f->myMethod(1,2); }
It should be noted that at this moment the bindings are static, that is, they depend not only on the GUIDs of the objects and DISPIDs of the methods, but also on the exact location of the VTable in the DLL. Any changes that affect vtable - for example, adding an additional method to the Foo base class will cause the method call to fail.
To use dynamic bindings, you can use the IFooDisp classes instead of IFooPtr . Again, these are smart wrappers that automatically control the life cycle of objects. Note that you must use a statement with these classes . for access to methods, and not for the indirectness operator -> . Using the indirectness operator will invoke the method, but through static binding.
{ IFooDisp f; ... f.myMethod(1,2); }
Using these wrappers based on IDispatch , methods will be dispatched by their DISPID, even if the format of the vtable objects is changed. I think that these classes also make it possible to send by function name, not DISPID, but did not confirm the details of this.
Roddy source share