Board index » delphi » Using Dispatch interfaces vs interfaces

Using Dispatch interfaces vs interfaces

Automating Excel 97 i used calls using next properties

WS.Range['A1', 'A1'].NumberFormat := Format;'C1', 'D4'];
or
WS.Cells
or
Excel.ActiveCell

But looking in the Excel_tlb.pas I find that all this properties return an
dispinterface called Range, this makes me think that I am using late binding
(very slow). In the same file I found an interface called IRange, but i
can't use the "as" sentence for cast a Range to IRange for use early binding
(more fast). Is this correct?

Can anybody Help me?
Thanks for advanced.

 

Re:Using Dispatch interfaces vs interfaces


<<Ramiro Bautista:
But looking in the Excel_tlb.pas I find that all this
properties return an dispinterface called Range, this makes
me think that I am using late binding (very slow).

Quote

In late binding with variants, any function call you make
has to go through the IDispatch methods GetIdsOfNames and
Invoke, before the method you actually want is called.
Using dispinterfaces, GetIdsOfnames does not have to be
called, so dispinterfaces are faster than late binding; but
Invoke is still called, so they are not as fast as normal
interfaces. Unfortunately, Microsoft is not obliged to make
the latter available to us. So many things are returned as
OleVariants or plain IDispatch interfaces anyway that a
dispinterface here or there really makes very little
difference.

--
Deborah Pate

Other Threads