您的位置:首页 > 其它

Inno Setup安装、卸载时判断是否程序正在运行

2013-02-02 14:09 776 查看
var
 
ErrorCode: Integer;
 
IsRunning: Integer; 

// 安装时判断客户端是否正在运行
 
function InitializeSetup(): Boolean;
 
begin
 
Result :=true; //安装程序继续
 
IsRunning:=FindWindowByWindowName('E家人客户端');
 
while IsRunning<>0 do
 
begin
 
if Msgbox('安装程序检测到客户端正在运行。' #13#13 '您必须先关闭它然后单击“是”继续安装,或按“否”退出!', mbConfirmation, MB_YESNO) = idNO then
 
begin
 
Result :=false; //安装程序退出
 
IsRunning :=0;
 
end else begin
 
Result :=true; //安装程序继续
 
IsRunning:=FindWindowByWindowName('E家人客户端');
 
end;
 
end;
 
end;
 
// 卸载时判断客户端是否正在运行
 
function InitializeUninstall(): Boolean;
 
begin
 
Result :=true; //安装程序继续
 
IsRunning:=FindWindowByWindowName('E家人客户端');
 
while IsRunning<>0 do
 
begin
 
if Msgbox('安装程序检测到客户端正在运行。' #13#13 '您必须先关闭它然后单击“是”继续安装,或按“否”退出!', mbConfirmation, MB_YESNO) = idNO then
 
begin
 
Result :=false; //安装程序退出
 
IsRunning :=0;
 
end else begin
 
Result :=true; //安装程序继续
 
IsRunning:=FindWindowByWindowName('E家人客户端');
 
end;
 
end;
 
end;
 
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
 
begin
 
case CurUninstallStep of
 
usUninstall:
 
begin // 开始卸载
 
end;
 
usPostUninstall:
 
begin // 卸载完成
 
// MsgBox('CurUninstallStepChanged:' #13#13 'Uninstall just finished.', mbInformation, MB_OK);
 
// ...insert code to perform post-uninstall tasks here...
 
ShellExec('open', 'http://domain', '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode);
 
end;
 
end;
 
end;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: