NSIS——安装、卸载时检查程序是否正在运行

来自:http://hi.baidu.com/langyanqi/blog/item/6cc9a41e895a5610413417bf.html

需要使用插件FindProcDLL.dll,下载路径:http://nsis.sourceforge.net/FindProcDLL_plug-in

;开始安装时检查是否正在运行
;${PRODUCT_NAME_EN}为自定义的常量

Function .onInit
FindProcDLL::FindProc "${PRODUCT_NAME_EN}.exe"
   Pop $R0
   IntCmp $R0 1 0 no_run
   MessageBox MB_ICONSTOP "安装程序检测到 ${PRODUCT_NAME_CN} 正在运行,请退出程序后重试"
   Quit
   no_run:

FunctionEnd

;开始卸载时检查:
Function un.onInit
FindProcDLL::FindProc "${PRODUCT_NAME_EN}.exe"
   Pop $R0
   IntCmp $R0 1 0 no_run
   MessageBox MB_ICONSTOP "安装程序检测到 ${PRODUCT_NAME_CN} 正在运行,请退出程序后重试"
   Quit
   no_run:
FunctionEnd

posted on 2012-09-19 18:18  learn铭记  阅读(300)  评论(0)    收藏  举报