[Dropped] AOO task still running after Delphi program terminates

Java, C++, C#, Delphi... - Using the UNO bridges
Post Reply
gavinsbtm
Posts: 2
Joined: Wed Sep 15, 2021 4:36 pm

[Dropped] AOO task still running after Delphi program terminates

Post by gavinsbtm »

I'm writing a delphi 10.3 program and testing on Windows 10.

When I run the terminate command on a com.sun.star.frame.Desktop object, the office task remains running in the background and can be seen on the windows task manager. The following is the most simple version of the code i'm using to replicate this.

Code: Select all

procedure TForm1.Button1Click(Sender: TObject);
var
  ooServiceManager, ooDesktop: Variant;

begin
  ooServiceManager := CreateOleObject('com.sun.star.ServiceManager');
  ooDesktop := ooServiceManager.CreateInstance('com.sun.star.frame.Desktop');
  ooDesktop.Terminate;
end;
I can force the task to terminate by sunning

Code: Select all

ShellExecute(0, nil, 'c:\windows\system32\taskkill.exe', '/F /iM soffice.bin', nil, SW_HIDE);
but that seems a bit hacky...

How do I terminate the office task using the service manager or desktop?
Last edited by MrProgrammer on Wed Feb 28, 2024 7:26 pm, edited 1 time in total.
Reason: Dropped: No response from gavinsbtm -- MrProgrammer, forum moderator
OpenOffice 3.1 on Windows Vista / NeoOffice 2.2.3 with MacOS 10.4 / OpenOffice 2.4 on Ubuntu 9.04
User avatar
RoryOF
Moderator
Posts: 34613
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Office task still running after delphi program terminate

Post by RoryOF »

Possibly relevant discussion and methods at
viewtopic.php?f=20&t=73209
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
gavinsbtm
Posts: 2
Joined: Wed Sep 15, 2021 4:36 pm

Re: Office task still running after delphi program terminate

Post by gavinsbtm »

RoryOF wrote:Possibly relevant discussion and methods at
viewtopic.php?f=20&t=73209
I've tried looping through and closing any open docs - no joy.

It seems to happen even without creating an instance of com.sun.star.frame.Desktop.

The following code has the same result

Code: Select all

procedure TForm1.Button1Click(Sender: TObject);
var
  ooServiceManager: Variant;
begin
  form1.caption := 'Started';

  ooServiceManager := CreateOleObject('com.sun.star.ServiceManager');

  ooServiceManager.dispose;

  form1.caption := 'Finished';
end;
OpenOffice 3.1 on Windows Vista / NeoOffice 2.2.3 with MacOS 10.4 / OpenOffice 2.4 on Ubuntu 9.04
User avatar
Lupp
Volunteer
Posts: 3549
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: Office task still running after delphi program terminate

Post by Lupp »

You sure that all the frames created by the desktop were closed and there can't be a veto?

Just for curiosity: What bridge did you use? Does it (or a variant of it) also work with FreePascal/Lazarus? Under different OS?


<edit>
Did you read viewtopic.php?f=5&t=40059 ?
</edit>
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
Post Reply