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

    技术2022-05-14  10

    [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;


    最新回复(0)