安装程序 – 安装更新之前关闭运行的程序版本(Inno Setup)
发布时间:2020-12-15 10:05:32 所属栏目:大数据 来源:网络整理
导读:这应该很简单,当安装程序启动时,我需要停止任何先前版本的程序运行. 大多数人建议做一个exe这样做,并在Inno Setup启动之前调用它.我使用AutoIt创建了一个exe,它会杀死我的程序的所有进程.问题是我不知道如何让Inno安装程序在安装任何东西之前调用它. 安装文
这应该很简单,当安装程序启动时,我需要停止任何先前版本的程序运行.
大多数人建议做一个exe这样做,并在Inno Setup启动之前调用它.我使用AutoIt创建了一个exe,它会杀死我的程序的所有进程.问题是我不知道如何让Inno安装程序在安装任何东西之前调用它. 安装文件之前如何调用可执行文件? 或者,如果我可以检测到一个程序是否正在运行,并告诉用户将其关闭,那么这也是可行的. 解决方法
如果应用程序有一个Mutex,您可以在Inno Setup安装程序中添加一个AppMutex值,并显示一条消息,告诉用户停止该程序.您可以通过使用SysInternals Process Explorer并选择程序/进程并查看下方窗格中的句柄(CTRL-H)来找到Mutex(如果有的话).
以下是提供几种方法的KB文章的链接: 或者,您可以在InitializeSetup中尝试此(UNTESTED)代码: [Setup] ;If the application has Mutex,uncomment the line below,comment the InitializeSetup function out,and use the AppMutex. ;AppMutex=MyApplicationMutex [Code] const WM_CLOSE = 16; function InitializeSetup : Boolean; var winHwnd: Longint; retVal : Boolean; strProg: string; begin Result := True; try //Either use FindWindowByClassName. ClassName can be found with Spy++ included with Visual C++. strProg := 'Notepad'; winHwnd := FindWindowByClassName(strProg); //Or FindWindowByWindowName. If using by Name,the name must be exact and is case sensitive. strProg := 'Untitled - Notepad'; winHwnd := FindWindowByWindowName(strProg); Log('winHwnd: ' + IntToStr(winHwnd)); if winHwnd <> 0 then Result := PostMessage(winHwnd,WM_CLOSE,0); except end; end; (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |