论坛风格切换切换到宽版
  • 6890阅读
  • 12回复

【已解决】套用网上的卸载判断代码为什么不起作用 [复制链接]

上一主题 下一主题
离线solan

发帖
80
金钱
800
威望
80
只看该作者 10 发表于: 2015-11-22
请问1楼的代码该怎么改
离线solan

发帖
80
金钱
800
威望
80
只看该作者 11 发表于: 2015-11-22
  1. function InitializeSetup():boolean;
  2. var
  3.   ResultCode: Integer;
  4.   IsRunning: Integer;
  5. begin
  6. Result :=true;  //安装程序继续
  7.   Exec(ExpandConstant('{cmd}'), 'for /f %%i ' +
  8.          'in (''reg query "HKCU\Software\KL\Running Applications"^|findstr /i /r /c:"^ *KL V26\.5 [0-9][0-9]*"^|find /c /v ""'') ' +
  9.          'do set IsRunning=%%i'
  10.          ,ExpandConstant('{app}'), SW_SHOWNORMAL, ewNoWait, ResultCode);
  11.   while IsRunning<>0 do
  12.   begin
  13.     if Msgbox('安装程序检测到KL8.5正在运行。'  #13#13 '您必须先关闭它然后单击“是”继续安装,或则按“否”退出!', mbConfirmation, MB_YESNO) = idNO then
  14.     begin
  15.       Result :=false; //安装程序退出
  16.       IsRunning :=0;
  17.     end else
  18.     begin
  19.         Exec(ExpandConstant('{cmd}'), 'for /f %%i ' +
  20.          'in (''reg query "HKCU\Software\KL\Running Applications"^|findstr /i /r /c:"^ *KL V26\.5 [0-9][0-9]*"^|find /c /v ""'') ' +
  21.          'do set IsRunning=%%i'
  22.          ,ExpandConstant('{app}'), SW_SHOWNORMAL, ewNoWait, ResultCode);
  23.     end;
  24.   end;
  25. end;
  26. end;
  27. function InitializeUninstall(): Boolean;
  28. var
  29.   IsRunning: Integer;
  30. begin
  31.   Result :=true;  //卸载程序继续
  32.   Exec(ExpandConstant('{cmd}'), 'for /f %%i ' +
  33.          'in (''reg query "HKCU\Software\KL\Running Applications"^|findstr /i /r /c:"^ *KL V26\.5 [0-9][0-9]*"^|find /c /v ""'') ' +
  34.          'do set IsRunning=%%i'
  35.          ,ExpandConstant('{app}'), SW_SHOWNORMAL, ewNoWait, ResultCode);
  36.   while IsRunning<>0 do
  37.   begin
  38.     if Msgbox('安装程序检测到KL8.5正在运行。'  #13#13 '您必须先关闭它然后单击“是”继续卸载,或则按“否”退出!', mbConfirmation, MB_YESNO) = idNO then
  39.     begin
  40.       Result :=false; //卸载程序退出
  41.       IsRunning :=0;
  42.     end else
  43.     begin
  44.        Exec(ExpandConstant('{cmd}'), 'for /f %%i ' +
  45.          'in (''reg query "HKCU\Software\KL\Running Applications"^|findstr /i /r /c:"^ *KL V26\.5 [0-9][0-9]*"^|find /c /v ""'') ' +
  46.          'do set IsRunning=%%i'
  47.          ,ExpandConstant('{app}'), SW_SHOWNORMAL, ewNoWait, ResultCode);
  48.     end;
  49.   end;
  50. end;



我瞎搞了一阵,但是运行上面代码,出现报警



离线solan

发帖
80
金钱
800
威望
80
只看该作者 12 发表于: 2015-12-15