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

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;

上一篇:DMA 内存存取原理


下一篇:Permutation test: p, CI, CI of P 置换检验相关统计量的计算