在应用程序运行时如何停止卸载 [英] How to stop uninstallation when the application is running
本文介绍了在应用程序运行时如何停止卸载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果该应用程序正在运行,并且用户尝试卸载该应用程序,那么我想阻止卸载.
帮帮我....
Hi,
If the application is running and the user tries to uninstall the application then I want to prevent the uninstallation.
Help me out....
推荐答案
我建议您在安装项目中创建一个自定义操作以覆盖OnBeforeUninstall()函数,然后在其中取消.遵循以下原则:
I would recommend creating a custom action in your setup project to override the OnBeforeUninstall() function, and cancel it in there. Something along these lines:
protected override void OnBeforeUninstall(IDictionary savedState)
{
base.OnBeforeUninstall(savedState);
if(Process.GetProcessesByName("nameOfYourProcess").Length > 0)
{
throw new InstallException("Cannot uninstall while appname is running.");
}
}
这篇关于在应用程序运行时如何停止卸载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文