INNO安装卸载自动结束进程插件使用

[Code]

//安装前判断是否有进程正在运行,istask.dll文件与打包的exe文件一起
function RunTask(FileName: string; bFullpath: Boolean): Boolean;
external 'RunTask@files:ISTask.dll stdcall delayload';
function KillTask(ExeFileName: string): Integer;
external 'KillTask@files: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 'RunTask@{app}/ISTask.dll stdcall delayload uninstallonly';
function KillTaskU(ExeFileName: string): Integer;
  external 'KillTask@{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;

你可能感兴趣的:(function,String,Integer,exe)