Request that another app shuts down.

Windows specific forum
jassing
Addict
Addict
Posts: 1775
Joined: Wed Feb 17, 2010 12:00 am

Request that another app shuts down.

Post by jassing »

Ideally (for me) I want to be able to send a message to another app that mimics a windows-shutdown-message so the app will close its files & exit.
If that's not possible, I can be a shell that runs it, then just terminates it; but I really want to be sure it's file buffers are all flushed .

Any ideas?

thanks.
User avatar
Mijikai
Addict
Addict
Posts: 1360
Joined: Sun Sep 11, 2016 2:17 pm

Re: Request that another app shuts down.

Post by Mijikai »

Try to send a close message:

Code: Select all

SendMessage_(WindowHandle.i,#WM_CLOSE,#Null,#Null)
Usually this should work (theres also #WM_QUIT).
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4664
Joined: Sun Apr 12, 2009 6:27 am

Re: Request that another app shuts down.

Post by RASHAD »

Hi jassing
Long time no see

Code: Select all

SendMessage_(#HWND_BROADCAST, #WM_SYSCOMMAND, #SC_CLOSE, hWnd)
Egypt my love
jassing
Addict
Addict
Posts: 1775
Joined: Wed Feb 17, 2010 12:00 am

Re: Request that another app shuts down.

Post by jassing »

RASHAD wrote:Hi jassing
Long time no see
Thanks; indeed it has been a while. I moved & took a little time off from Windows work...
Hope you have been well.
RASHAD wrote:

Code: Select all

SendMessage_(#HWND_BROADCAST, #WM_SYSCOMMAND, #SC_CLOSE, hWnd)
Mijikai wrote:Try to send a close message:

Code: Select all

SendMessage_(WindowHandle.i,#WM_CLOSE,#Null,#Null)
Usually this should work (theres also #WM_QUIT).
Thanks; I'll give those three a try. I fear the app I am trying to close gracefully isn't listening. I am trying to close an inventory & billing app down so that it's data file can be backed up at night. The problem is the app doesn't appear to flush its file buffers to disk, so if I kill the app, the data file doesn't contain some of the last updates...

I appreciate the quick replies. Thanks!
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: Request that another app shuts down.

Post by Dude »

I've found the #SC_CLOSE version is better than #WM_CLOSE, because #WM_CLOSE wouldn't close some windows on my PC (but #SC_CLOSE did).

[Edit] Here's my previous post about it: viewtopic.php?p=509365#p509365
Last edited by Dude on Mon Oct 01, 2018 3:55 am, edited 1 time in total.
jassing
Addict
Addict
Posts: 1775
Joined: Wed Feb 17, 2010 12:00 am

Re: Request that another app shuts down.

Post by jassing »

Dude wrote:I've found the #SC_CLOSE version is better than #WM_CLOSE, because #WM_CLOSE wouldn't close some windows on my PC (but #SC_CLOSE did).
I guess it's all a matter of what the app is listening for, conventions are there for a reason, but it doesn't mean apps have to follow them.
Post Reply