artifixer
artifixer

Reputation: 39

Working with MSWord using OLE in Delphi 10.3

I have a strange situation with the performance issues when accessing MSWord using OLE in Delphi 10. Those issues are inconsistent between different users, and we started to get the reports of them after we moved our project from XE to 10.3.

I've simplified the example to the most basic level: created a new VCL application project and put a button on a form with the following code:

procedure TForm1.Button1Click(Sender: TObject);
var
  W: OleVariant;
begin
  W := CreateOleObject('Word.Application');
  W.Quit;
  W := Unassigned;
end;

It works fine on my computer, but freezes for about a minute after exiting the procedure on my colleague's computer, who also have performance issues with the real product. We both work on fairly powerful computers with Win10 x64 systems.

What could be the reason for such a lengthy halt while exiting the routine? Any ideas how to avoid it?

Upvotes: 0

Views: 356

Answers (1)

Quelltextknecht
Quelltextknecht

Reputation: 237

Your doing nothing special.

On the Delphi Side there should be no difference, i would bet the Same is bound to happen with your older Delphi Version on the exact same code.

First thing i would Check: Is the automatic generated Code for Word the same? Then i can´t remember the details but there is a difference. For Office Applications you can get a COM Pointer to a running Application or start one. With another Call you get everytime your "own" Instance for your Application alone.

But i think thats unlikely to be the cause in your minimal Scenario.

So another guess would be: It´s a function Inside the COM Object thats reacting. I would recommend to log the Actions of Word with ProcessMonitor. Filter everything exept Word or the PID of your Instance. You should find whats holding up Word in the log. (Registry, Network or Files)

Upvotes: 1

Related Questions