本文介绍了卸载前检查应用程序是否在 NSIS 中运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 NSIS 的新手,我需要知道在卸载程序中,如何检查应用程序(使用 C++)是否正在运行并在卸载前关闭它.

I am new to NSIS, and I need to know that in the uninstaller, how I can check if the application (which is in C++) is running and close it before uninstalling.

推荐答案

这是使用 NSProcess 的稍微更友好的版本请求应用关闭而不是终止它(欧文的回答)

Here is a slightly more friendly version for using NSProcess that requests the app to close rather than terminates it (Owen's answer)

${nsProcess::FindProcess} "${APP_EXE}" $R0

${If} $R0 == 0
    DetailPrint "${AppName} is running. Closing it down"
    ${nsProcess::CloseProcess} "${APP_EXE}" $R0
    DetailPrint "Waiting for ${AppName} to close"
    Sleep 2000  
${Else}
    DetailPrint "${APP_EXE} was not found to be running"        
${EndIf}    

${nsProcess::Unload}

这篇关于卸载前检查应用程序是否在 NSIS 中运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 14:44