So, how can we speed things up?
Well, the worst bottleneck is the name lookup, and that's something we can deal with! We usually know all the METHOD definitions at compile-time. If we can tell the compiler the DispID's and the parameter info at compile-time, one whole step can be eliminated! That's called ID-BINDING of the Dispatch Interface. We create a simple IDBIND Interface, which is written like this:
INTERFACE IDBIND MyDispIfaceName
MEMBER CALL Method1<77> (WideVal AS LONG, WideText AS
WSTRING)
MEMBER CALL Method2<78> ()
MEMBER CALL MethodX<79> ()
END INTERFACE
PowerBASIC can use this IDBIND Interface to create faster Dispatch execution. Just create this structure, and place it in your source code prior to any references. Then, when you create an object variable, just use the IDBIND Interface Name instead of DISPATCH:
LOCAL DispVar AS MyDispIfaceName
LET DispVar = NEWCOM "DispProgID"
OBJECT CALL DispVar.Method1(abc&, xyz$$)
"ID Binding" is faster than "Late Binding", but you must supply interface definitions in your source code. |
How do you get this information? Most likely from the PowerBASIC COM Browser! At your convenience, it will scan your system registry, and find any COM objects available. It will create all of the Interface definitions for you with just a click.
See Also