• innosetup 安装前、卸载前判断是否有进程正在运行<转>


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

    转:https://blog.csdn.net/dsp_daiyujie/article/details/11945871

  • 相关阅读:
    贝叶斯公式推导
    三种常量池
    SpringCloud使用Feign实现服务间通信
    springCloud配置本地配中心SpringCloudConfig
    SpringApplication执行流程
    调用shutdown.sh后出现could not contact localhost8005 tomcat may not be running报错问题
    TCP协议详解
    web.xml配置说明
    第一份offer
    博客CSS
  • 原文地址:https://www.cnblogs.com/wainiwann/p/9776716.html
Copyright © 2020-2023  润新知