zoukankan      html  css  js  c++  java
  • 如何运用inno在安装和卸载时提示用户结束进程?

    我尝试着写了一段,但是卸载段存在问题,请指点!

    CODE

    [Files]
    Source: ISTask.dll; DestDir: {app}; Flags: ignoreversion

    [Code]
    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('MyProg.exe', false) then
      begin
        if MsgBox('安装程序检测到 MyProg.exe 正在运行!'#13''#13'单击“是”按钮关闭 LockOn 程序;'#13''#13'单击“否”按钮进行强制安装!', mbConfirmation, MB_YESNO) = IDYES then
          KillTask('MyProg.exe');
      end
    end;

    function InitializeUninstall(): Boolean;
    begin
    Result:= true;
      if RunTask('MyProg.exe', false) then
      begin
        if MsgBox('安装程序检测到 MyProg.exe 正在运行!'#13''#13'单击“是”按钮关闭 LockOn 程序;'#13''#13'单击“否”按钮进行强制安装!', mbConfirmation, MB_YESNO) = IDYES then
          KillTask('MyProg.exe');
      end
    end;

    ======================================================

    ======================================================

    ======================================================

    用上面的代码,在卸载时判断进程的dll已经没有了,所以不能调用它的函数。其实安装和卸载时调用的dll是不同的。

    这样修改代码应该可以:

    CODE

    [Files]
    Source: ISTask.dll; DestDir: {app}; Flags: ignoreversion

    [Code]
    function RunTask1(FileName: string; bFullpath: Boolean): Boolean;
    external 'RunTask@files:ISTask.dll stdcall delayload';

    function KillTask1(ExeFileName: string): Integer;
    external 'KillTask@files:ISTask.dll stdcall delayload';

    function RunTask(FileName: string; bFullpath: Boolean): Boolean;
    external 'RunTask@{app}ISTask.dll stdcall uninstallonly';

    function KillTask(ExeFileName: string): Integer;
    external 'KillTask@{app}ISTask.dll stdcall uninstallonly';

    function InitializeSetup(): Boolean;
    begin
    Result:= true;
      if RunTask1('MyProg.exe', false) then
      begin
        if MsgBox('安装程序检测到 MyProg.exe 正在运行!'#13''#13'单击“是”按钮关闭 LockOn 程序;'#13''#13'单击“否”按钮进行强制安装!', mbConfirmation, MB_YESNO) = IDYES then
          KillTask1('MyProg.exe');
      end
    end;

    function InitializeUninstall(): Boolean;
    begin
    Result:= true;
      if RunTask('MyProg.exe', false) then
      begin
        if MsgBox('安装程序检测到 MyProg.exe 正在运行!'#13''#13'单击“是”按钮关闭 LockOn 程序;'#13''#13'单击“否”按钮进行强制安装!', mbConfirmation, MB_YESNO) = IDYES then
          KillTask('MyProg.exe');
        UnloadDll(ExpandConstant('{app}ISTask.dll'));
      end
    end;

  • 相关阅读:
    java内存模型
    如何保证消费者接收消息的顺序
    mysql事务隔离级别
    mysql加锁读
    mysql一致性读
    InnoDB锁
    JDK1.8中的线程池
    JDK1.8中HashMap实现
    物品推荐(基于物品的协同过滤算法)
    CRM 2013 生成自动编号
  • 原文地址:https://www.cnblogs.com/joean/p/4938095.html
Copyright © 2011-2022 走看看