【NSIS使用经验】禁止多个安装程序实例或禁止重复安装程序

;在安装程序运行前的回调函数前实现
Function .onInit
;禁止多个安装程序实例
System::Call ‘kernel32::CreateMutexA(i 0, i 0, t “JWBClient”) i .r1 ?e’
Pop $R0
StrCmp $R0 0 +3
MessageBox MB_OK|MB_ICONEXCLAMATION “安装程序已经在运行。”
Abort

;禁止重复安装程序
ReadRegStr $0 HKLM ‘${PRODUCT_DIR_REGKEY}’ “”
StrLen $1 $0
IntCmp $1 0 +3 +1 +1
MessageBox MB_OK|MB_USERICON ‘$(^Name) 已安装在计算机中。如需重新安装,请卸载已有的安装’
Quit
FunctionEnd

Leave a Reply

  

  

  

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>