#1 2021-01-07 19:05:23

edwinsn
Member
Registered: 2010-07-02
Posts: 1,218

SynCommons.SynVarDispProc interfering MS Word automation?

Hello Arnaud,

My program uses Word automation late-binding, and today I found some EOleException errors are related to`SynCommons.SynVarDispProc`, in the following line:

      // process Ole Automation variants
      if Assigned(VarDispProc) then
        VarDispProc(pointer(Result),Variant(Instance),CallDesc,@Params); // line 46521

It's weird, it's not clear to me why madExcept's reports error in`SynCommons.SynVarDispProc` when calling a Word document object.

Do you think if the OleVariant interception by SynCommons will cause any EOleException with message like "command failed" and so on? How to avoid SynCommons.SynVarDispProc to be called?

Thanks.

Call stack:

00696a6f +0bf app1.exe System.Win.ComObj                    DispatchInvokeError
006963e1 +1f1 app1.exe System.Win.ComObj                    DispatchInvoke
00696992 +0b2 app1.exe System.Win.ComObj                    VarDispInvoke
008cc0b3 +0d3 app1.exe SynCommons                46521  +10 SynVarDispProc
017e8517 +167 app1.exe MyUnit1                     165  +35 MyClass1.Method1 // here the program calls the OleVariant

Last edited by edwinsn (2021-01-07 19:12:14)


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#2 2021-01-07 21:48:38

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: SynCommons.SynVarDispProc interfering MS Word automation?

Try to disable DOPATCHDISPINVOKE conditional around line 46585.

Offline

#3 2021-01-08 05:46:35

edwinsn
Member
Registered: 2010-07-02
Posts: 1,218

Re: SynCommons.SynVarDispProc interfering MS Word automation?

ab wrote:

Try to disable DOPATCHDISPINVOKE conditional around line 46585.

I will try, but I found two lines of comments about this conditional define:
  // we NEED our patched DispInvoke to circumvent some Delphi bugs on Win64
  // to circumvent LIdent := Uppercase() in TInvokeableVariantType.DispInvoke()

Are these two items still true?


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#4 2021-01-08 09:01:21

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: SynCommons.SynVarDispProc interfering MS Word automation?

Only if you use TDocVariant with late binding.

Offline

#5 2021-01-08 10:26:32

edwinsn
Member
Registered: 2010-07-02
Posts: 1,218

Re: SynCommons.SynVarDispProc interfering MS Word automation?

I'm in trouble then... I use TDocVariant with late binding...


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#6 2021-01-08 10:29:01

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: SynCommons.SynVarDispProc interfering MS Word automation?

You won't have any trouble on XE4.
The patch is mandatory only for Delphi 5 and Delphi 6. Read the context of the comment.

Offline

#7 2021-01-08 10:46:52

edwinsn
Member
Registered: 2010-07-02
Posts: 1,218

Re: SynCommons.SynVarDispProc interfering MS Word automation?

@ab,
That's Great! But since the comments (posted below) didn't mention any Delphi versions and the code is either `{$ifdef  DELPHI6OROLDER}` or `{$ifdef CPU64}`, so I actually couldn't read the info you provided above...

But thank you all the same!

{$ifdef DOPATCHTRTL}
  {$define DOPATCHDISPINVOKE} // much faster late-binding process for our types
{$endif}
{$ifdef CPU64}
  {$define DOPATCHDISPINVOKE}
  // we NEED our patched DispInvoke to circumvent some Delphi bugs on Win64
{$endif}
{$ifdef DELPHI6OROLDER}
  {$define DOPATCHDISPINVOKE}
  // to circumvent LIdent := Uppercase() in TInvokeableVariantType.DispInvoke()
{$endif}

{$endif FPC}

Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

Board footer

Powered by FluxBB