INNO安装卸载自动结束进程插件使用
2013年09月21日 ⁄ 综合 ⁄ 共 1355字 ⁄ 字号 小 中 大 ⁄ 评论关闭
[Code]
//安装前判断是否有进程正在运行,istask.dll文件与打包的exe文件一起
function RunTask(FileName: string; bFullpath: Boolean): Boolean;
external ‘[email protected]:ISTask.dll stdcall delayload‘;
function KillTask(ExeFileName: string): Integer;
external ‘[email protected]:ISTask.dll stdcall delayload‘;
function InitializeSetup(): Boolean;
begin
Result:= true;
if RunTask(‘{#MyAppExeName}‘, false) then
begin
if MsgBox(‘安装程序检测到 {#MyAppName} 正在运行!‘#13‘‘#13‘单击“是”按钮关闭程序并继续安装;‘#13‘‘#13‘单击“否”按钮退出安装!‘, mbConfirmation, MB_YESNO) = IDYES then
begin
KillTask(‘{#MyAppExeName}‘);
Result:= true;
end
else
Result:= false;
end
else Result:= true;
end;
// 卸载前判断进程是否在运行
function RunTaskU(FileName: string; bFullpath: Boolean): Boolean;
external ‘[email protected]{app}/ISTask.dll stdcall delayload uninstallonly‘;
function KillTaskU(ExeFileName: string): Integer;
external ‘[email protected]{app}/ISTask.dll stdcall delayload uninstallonly‘;
function InitializeUninstall(): Boolean;
begin
Result:= true;
if RunTaskU(‘{#MyAppExeName}‘, false) then
begin
if MsgBox(‘卸载程序检测到 {#MyAppName}
正在运行!‘#13‘‘#13‘单击“是”按钮关闭程序并继续卸载;‘#13‘‘#13‘单击“否”按钮退出卸载!‘, mbConfirmation,
MB_YESNO) = IDYES then
begin
KillTaskU(‘{#MyAppExeName}‘);
Result:= true;
end
else
Result:= false;
end
else
Result:= true;
UnloadDll(ExpandConstant(‘{app}/ISTask.dll‘));
end;