大佬教程收集整理的这篇文章主要介绍了inno-setup – Inno Setup – 防止同时多次执行安装程序,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
SetupMutex
指令:
[Setup] AppId=MyProgram SetupMutex=SetupMutex{#SetupSetTing("AppId")}@H_197_2@如果要更改已在另一个安装程序运行时显示的消息文本,请使用:
[messages] SetupAppRunningError=Setup has detected that %1 is currently running.%n%nPlease close all instances of it now,then click OK to conTinue,or Cancel to exit.@H_197_2@在此版本之前,没有可用的内置机制.但你可以简单地写自己的.原则是您在安装程序启动时创建一个唯一的互斥锁.但是,首先检查是否已经创建了这样的互斥锁.如果是,则退出设置,否则,创建互斥锁:
[Setup] AppName=My Program AppVersion=1.5 DefaultDirName={pf}\My Program [Code] const // this needs to be system-wide unique name of the mutex (up to MAX_PATH long),// there is a discussion on this topic https://stackoverflow.com/q/464253/960757 // you can expand here e.g. the AppId directive and add it some 'salt' MySetupMutex = 'My Program Setup 2336BF63-DF20-445F-AAE6-70FD7E2CE1CF'; function InitializeSetup: Boolean; begin // allow the setup to run only if there is no thread owning our mutex (in other // words it means,there's no other instance of this process running),so allow // the setup if there is no such mutex (there is no other instancE) Result := not checkForMutexes(MySetupMuteX); // if this is the only instance of the setup,create our mutex if Result then CreateMutex(MySetupMuteX) // otherwise tell the user the setup will exit else MsgBox('Another instance is running. Setup will exit.',mbError,MB_OK); end;@H_618_4@ @H_618_4@
以上是大佬教程为你收集整理的inno-setup – Inno Setup – 防止同时多次执行安装程序全部内容,希望文章能够帮你解决inno-setup – Inno Setup – 防止同时多次执行安装程序所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。