开发者

What does WIX's CloseApplication functionality do and how would can the application respond to such a signal

In the WIX setup I've got, when upgrading the application I have set a requirement to close down applications which might hold on to files which needs to be updated:

<util:CloseApplication
    Id="CloseMyApp" 
    Target="[MyAppExe]"
    CloseMessage="yes"
    Description="!(loc.MyAppStillRunning)"
    RebootPrompt="no"
    ElevatedCloseMessage="no"
/>

The application on the other hand will capture closing down the window with a "user friendly" dialog box where the user can confirm that he or she wants to close down the application.

When the installer runs CloseApplication it finds that the application must be stopped, but it fails to close my application. One theory is that the dialog box stops the application fr开发者_开发知识库om closing.

So the question is: Could this be a possible problem? If so - how can I have this confirmation dialog box and still behave properly when the installer asks the application to close down? Must I listen to Win32 messages (such as WM_QUIT/WM_CLOSE) or is there a .NET API which I can use to respond properly to these events?

Update: According to mailinglist, CloseApplication will send WM_CLOSE to the application. I still have the issue with having different behavior if the user closes the app vs. a close message sent by WIX. Not sure how I can identify different sources of how the application closes.


Your application should get a WM_CLOSE which should surface in your .NET app as a "Closing" event on your main form. In processing that, you can use the Win32 API GetLastActivePopup to check for any active dialog boxes you have open and close them as appropriate.

You can test your implementation by opening task manager and doing an "End Process" on your application. That will try to do a gentle shutdown first using a method similar to what WiX is probably doing.


When the VM_CLOSE gets send to my WPF application, I get as Jim mentions a Closing event. In that closing event I do a check on the IsFocused property on my Window class. When this returns false, I quit the application without any user confirmation.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜