inno安装卸载时检测程序是否正在运行卸载完成后自动打开网页-代码无效

时间:2023-12-18 17:21:14

inno安装卸载时检测程序是否正在运行卸载完成后自动打开网页-代码无效

inno setup 安装卸载时检测程序是佛正在运行卸载完成后自动打开网页-代码无效

--------------------------代码如下---------------------------

[Code]
var
ErrorCode: Integer;
IsRunning: Integer;

// 安装时判断客户端是否正在运行
function InitializeSetup(): Boolean;
begin
Result :=true; //安装程序继续
IsRunning:=FindWindowByWindowName('东方宽频网络电视');
while IsRunning<>0 do
begin
    if Msgbox('安装程序检测到客户端正在运行。' #13#13 '您必须先关闭它然后单击“是”继续安装,或按“否”退出!', mbConfirmation, MB_YESNO) = idNO then
    begin
      Result :=false; //安装程序退出
      IsRunning :=0;
    end else begin
      Result :=true; //安装程序继续
      IsRunning:=FindWindowByWindowName('东方宽频网络电视');
    end;
end;

end;

// 卸载时判断客户端是否正在运行
function InitializeUninstall(): Boolean;
begin
   Result :=true; //安装程序继续
IsRunning:=FindWindowByWindowName('东方宽频网络电视');
while IsRunning<>0 do
begin
    if Msgbox('安装程序检测到客户端正在运行。' #13#13 '您必须先关闭它然后单击“是”继续安装,或按“否”退出!', mbConfirmation, MB_YESNO) = idNO then
    begin
      Result :=false; //安装程序退出
      IsRunning :=0;
    end else begin
      Result :=true; //安装程序继续
      IsRunning:=FindWindowByWindowName('东方宽频网络电视');
    end;
end;
end;

procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
case CurUninstallStep of
    usUninstall:
      begin // 开始卸载

end;
    usPostUninstall:
      begin      // 卸载完成
        // MsgBox('CurUninstallStepChanged:' #13#13 'Uninstall just finished.', mbInformation, MB_OK);
        // ...insert code to perform post-uninstall tasks here...
        ShellExec('open', 'http://www.baidu.com', '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode);
      end;
end;
end;

请问“东方宽屏网络电视”是不是改成自己程序的名字

这些代码无效  怎没办 - -!!inno安装卸载时检测程序是否正在运行卸载完成后自动打开网页-代码无效

restools 2011-11-07 20:41
FindWindowByWindowName 只能查找完整的标题, 例如你的 标题是 MyApp ver 1.0
那么你只能用 FindWindowByWindowName('MyApp ver 1.0')
而不能用 FindWindowByWindowName('MyApp')
xwhminghan 2011-11-08 12:20
用插件吧,检测进程的插件,有好几个,而且都有例子的。你搜索一下就知道了。istask、IssProc、psvince
xwhminghan 2011-11-08 12:33
#define MyAppName "MyProgramm"
#define MyAppVersion "0.0.0.0"
#define MyAppURL "http://www.example.com/"
#define MyAppExeName "MyProg.exe"

[Files]
Source: {tmp}\psvince.dll; DestDir: {app}; Flags: ignoreversion; Attribs: hidden

[Code]
function IsModuleLoadedU(modulename: String ):  Boolean;
  external 'IsModuleLoaded@{app}\psvince.dll stdcall uninstallonly';

function InitializeUninstall(): Boolean;
begin
  if IsModuleLoadedU( '{#MyAppExeName}' ) then
  begin
    MsgBox('{#MyAppName} 正在运行,请尝试关闭后再点击[确定]按钮。',mbError, MB_OK);
    Result := false;
  end
  else
    Result := true;
    UnloadDLL(ExpandConstant('{app}\psvince.dll'));
end;

procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
  case CurUninstallStep of
    usPostUninstall:
      begin
        if MsgBox('访问作者的网站吗?', mbConfirmation, MB_YesNo or MB_DEFBUTTON1) = IDYes then
          ShellExec('open', '{#MyAppURL}', '', '', SW_SHOWNORMAL, ewWaitUntilTerminated, ErrorCode);
      end;
  end;
end;

lh822 2011-11-08 21:55
+_+ 看不懂  大家看下一下代码 ↓

--------------------------------------------------------------------------------------------------------------
; 脚本由 Inno Setup 脚本向导 生成!
; 有关创建 Inno Setup 脚本文件的详细资料请查阅帮助文档!

#define MyAppName "愤怒的小鸟"
#define MyAppVersion "1.0.0"
#define MyAppPublisher "Rovio"
#define MyAppExeName "AngryBirds.exe"

[Setup]
; 注: AppId的值为单独标识该应用程序。
; 不要为其他安装程序使用相同的AppId值。
; (生成新的GUID,点击 工具|在IDE中生成GUID。)
AppId={{3D8D1A6F-6154-4E87-9049-62C54FC56F69}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
DefaultDirName={pf}\{#MyAppName}
DefaultGroupName={#MyAppName}
OutputBaseFilename=愤怒的小鸟
Compression=lzma
SolidCompression=yes

[Languages]
Name: "chinesesimp"; MessagesFile: "compiler:Default.isl"

[Tasks]
Name:
"desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription:
"{cm:AdditionalIcons}"; Flags: unchecked; OnlyBelowVersion: 0,6.1

[Files]
Source: "E:\愤怒的小鸟\AngryBirds.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "E:\愤怒的小鸟\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
; 注意: 不要在任何共享系统文件上使用“Flags: ignoreversion”

[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon

[Run]
Filename:
"{app}\{#MyAppExeName}"; Description:
"{cm:LaunchProgram,{#StringChange(MyAppName, "&", "&&")}}";
Flags: nowait postinstall skipifsilent

----------------------------------------------------------------------------------------------

比如这个  ,要怎没弄才能实现  ,安装卸载时检测程序是否正在运行卸载完成后自动打开网页。
inno安装卸载时检测程序是否正在运行卸载完成后自动打开网页-代码无效

lh822 2011-11-17 14:13
; 脚本由 Inno Setup 脚本向导 生成!
; 有关创建 Inno Setup 脚本文件的详细资料请查阅帮助文档!

#define MyAppName "我的程序"
#define MyAppVersion "1.5"
#define MyAppPublisher "我的公司"
#define MyAppURL "http://www.example.com/"
#define MyAppExeName "AngryBirds.exe"

[Setup]
; 注: AppId的值为单独标识该应用程序。
; 不要为其他安装程序使用相同的AppId值。
; (生成新的GUID,点击 工具|在IDE中生成GUID。)
AppId={{84B08A76-86FA-4ADA-8943-4275F0CC0F21}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppName}
DefaultGroupName={#MyAppName}
OutputBaseFilename=setup
Compression=lzma
SolidCompression=yes

[Languages]
Name: "chinesesimp"; MessagesFile: "compiler:Default.isl"

[Tasks]
Name:
"desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription:
"{cm:AdditionalIcons}"; Flags: unchecked; OnlyBelowVersion: 0,6.1

[Files]
Source: "E:\愤怒的小鸟\AngryBirds.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "E:\愤怒的小鸟\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
; 注意: 不要在任何共享系统文件上使用“Flags: ignoreversion”

[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{group}\{cm:ProgramOnTheWeb,{#MyAppName}}"; Filename: "{#MyAppURL}"
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon

[Run]
Filename:
"{app}\{#MyAppExeName}"; Description:
"{cm:LaunchProgram,{#StringChange(MyAppName, "&", "&&")}}";
Flags: nowait postinstall skipifsilent
[Code]
var
ErrorCode: Integer;
IsRunning: Integer;

// 安装时判断客户端是否正在运行
function InitializeSetup(): Boolean;
begin
Result :=true; //安装程序继续
IsRunning:=FindWindowByWindowName('我的程序');
while IsRunning<>0 do
begin
    if Msgbox('安装程序检测到客户端正在运行。' #13#13 '您必须先关闭它然后单击“是”继续安装,或按“否”退出!', mbConfirmation, MB_YESNO) = idNO then
    begin
      Result :=false; //安装程序退出
      IsRunning :=0;
    end else begin
      Result :=true; //安装程序继续
      IsRunning:=FindWindowByWindowName('我的程序');
    end;
end;

end;

// 卸载时判断客户端是否正在运行
function InitializeUninstall(): Boolean;
begin
   Result :=true; //安装程序继续
IsRunning:=FindWindowByWindowName('我的程序');
while IsRunning<>0 do
begin
    if Msgbox('安装程序检测到客户端正在运行。' #13#13 '您必须先关闭它然后单击“是”继续安装,或按“否”退出!', mbConfirmation, MB_YESNO) = idNO then
    begin
      Result :=false; //安装程序退出
      IsRunning :=0;
    end else begin
      Result :=true; //安装程序继续
      IsRunning:=FindWindowByWindowName('我的程序');
    end;
end;
end;

procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
case CurUninstallStep of
    usUninstall:
      begin // 开始卸载

end;
    usPostUninstall:
      begin      // 卸载完成
        // MsgBox('CurUninstallStepChanged:' #13#13 'Uninstall just finished.', mbInformation, MB_OK);
        // ...insert code to perform post-uninstall tasks here...
        ShellExec('open', 'http://www.baidu.com', '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode);
      end;
end;
end;

这样怎么不对 。。。   %>_<%