张志峰的博客

水滴石川,积少成多。

导航

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

Posted on 2016-09-04 13:00  ╰★张志峰★╮  阅读(1448)  评论(0编辑  收藏  举报

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;