enhance(nsis): use restart manager to close app
Closes #9950 Closes https://github.com/tauri-apps/nsis-tauri-utils/issues/39 Reference https://github.com/tauri-apps/tao/issues/1115
Use Restart Manager to close running app instead of our own nsis_tauri_utils::KillProcess, this makes it so that we send a WM_ENDSESSION signal to the app for it to gracefully shutdown (paired with https://github.com/tauri-apps/tao/pull/1126)
This also fixed a problem where we would wrongly detect other programs that have the same name as us (e.g. both named api.exe) and shut them down
One more thing to go though, we should probably also switch nsis_tauri_utils::FindProcess to RmGetList and use a fully qualified path here, so we fully fix this problem
Package Changes Through f903f5d378d8d5c24da8234aa652f039dfc83eb6
There are 5 changes which include @tauri-apps/api with patch, tauri with patch, tauri-cli with patch, tauri-bundler with minor, @tauri-apps/cli with patch
Planned Package Versions
The following package releases are the planned based on the context of changes in this pull request.
| package | current | next |
|---|---|---|
| @tauri-apps/api | 2.9.0 | 2.9.1 |
| tauri-bundler | 2.7.3 | 2.8.0 |
| tauri | 2.9.3 | 2.9.4 |
| @tauri-apps/cli | 2.9.4 | 2.9.5 |
| tauri-cli | 2.9.4 | 2.9.5 |
Add another change file through the GitHub UI by following this link.
Read about change files or the docs at github.com/jbolda/covector
I know the code is a bit wacky, but honestly I can't quite think of anything better here
Since there's a cost with RmRegisterResources, I'm not sure if it makes sense to just replace the implementation in FindProcess and KillProcess
https://learn.microsoft.com/en-us/windows/win32/api/restartmanager/nf-restartmanager-rmregisterresources#:~:text=Each%20call%20to%20the%20RmRegisterResources%20function%20performs%20relatively%20expensive%20write%20operations.%20Do%20not%20call%20this%20function%20once%20per%20file%2C%20instead%20group%20related%20files%20together%20into%20components%20and%20register%20these%20together.
Actually, this will cause the app to crash on https://github.com/tauri-apps/tao/blob/3c2b4447aa53151ae96d30a60928d1d71e9bb5fc/src/platform_impl/windows/event_loop/runner.rs#L368 because Restart Manager works a bit differently from system shutdown, it doesn't terminate us right away after returning 0 from WM_ENDSESSION
Not sure if we should just call std::process::exit when we get WM_ENDSESSION to keep the behavior consistent though