Archive: Command or plugin to quit application gracefully?


Command or plugin to quit application gracefully?
Hello all,

I've been using the Processes::KillProcess to kill an application before update or before uninstallation, but we are looking for something that give the application time to gracefully shutdown. Any suggestion?

Many thanks!


well, you could send WM_CLOSE to the application:
http://msdn.microsoft.com/en-us/libr...17(VS.85).aspx

or you can try the relatively recent nsisDDE plugin:
http://forums.winamp.com/showthread.php?t=320701


Note: nsisDDE has been around for a long time now (2005) but there was no forum thread for it ;)
Version 1.1 was recently released and supports Unicode.


Originally posted by Wizou
Note: nsisDDE has been around for a long time now (2005) but there was no forum thread for it ;)
whoops! :)

Thanks for your responeses, Animaether and Wizou!

I tried as follow but it doesn't seem to close the program:

nsisDDE::Execute "notepad" "[FileQuit()]"
Pop $0
MessageBox MB_OK "Found $0 responding DDE server(s)"

The message value for $0 is 0.

I also try with nsisDDEW. What I do wrong here?

Thanks!


from the first google hit for 'notepad dde'..
"DDE (Dynamic Data Exchange) is one Microsoft way of communicating between applications that support that (e.g. Word does, but Wordpad/Notepad don't). Messages are strings that express commands"
..it seems notepad doesn't take DDE commands.

So if notepad is your target, WM_CLOSE may be what you're actually looking for. What are you trying to accomplish, exactly?


Thanks Animaether!

I am just trying to quit my application gracefully instead of using Processes::KillProcess to kill my application.

For example, my app is in the process of syncing a file, I would like to quit after the sync process is completed instead of kill the app right away.


Well, you'd have to look up the exact specs of that application's DDE server - if any (e.g. just like notepad, it might not have any) - to use the DDE method.
The alternative is the WM_CLOSE message, which the application should handle gracefully. However, the exact manner in which it handles this is less fine-grained than DDE might allow.

e.g. as per that same article, Microsoft Office Word can be told to close and - if a modified file is open - either save, don't save, or prompt the user.
with WM_CLOSE, it always prompts the user (similar to pressing the X button on the window)


@jdt2oo7 : If you have the source code of your application and it is written in MFC, it is quite easy to add DDE support.