Reputation: 23
Is there any good article that explains more about RestartManager and how to make the applications aware and handle the special messages in order to shutdown properly?
I have two applications that are installed with MSI installer build in Visual Studio Setup Project. One of this applications is WPF application and another one is a web API application that is running in Kestrel web server.
This two applications are running in background
When we have another version of the MSI installer, where the PackageCode and ProductCode are updated accordingly as the Version number, when you try yo install the new file the FileInUse window is displayed and the MSI Installer can't shutdown the running applications.
I found out about RestartManager and the Guidelines for applications -> https://learn.microsoft.com/en-us/windows/win32/rstmgr/guidelines-for-applications
But not sure how can I make my application to be aware of the RestartManager and to shutdown when update or uninstall is available.
My applications are installed in windows 10 or higher.
I tried to handle the WM_ENDSESSION message in my WPF application but that didn't worked correctly...
Upvotes: 0
Views: 50
Reputation: 101599
Call RegisterApplicationRestart
(WM_QUERYENDSESSION
is your last chance to call this but you may call it sooner).
What the exact command line should be is up to you, it may be as simple as /restart
or if you need to store state information in a specific file, you might need something like /restore "c:\myfolder\appstate.ini"
. When the restart manager starts your application, it will be launched with the command line parameters you registered.
Upvotes: 0