byGGqinbo 2016-12-06 07:56 采纳率: 0%
浏览 2904

用InnoSetup生成的安装程序,安装成功后再点击Setup.exe卸载,最后出现安装,怎么去掉呢

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

[Setup]
; 注: AppId的值为单独标识该应用程序。
; 不要为其他安装程序使用相同的AppId值。
; (生成新的GUID,点击 工具|在IDE中生成GUID。)
AppId={{5EF80699-C8CA-464E-94A7-0A87A8841A22}}
AppName=example
AppVersion=1.5
;AppVerName=example 1.5
AppPublisher=我的公司
AppPublisherURL=http://www.example.com/
AppSupportURL=http://www.example.com/
AppUpdatesURL=http://www.example.com/
DefaultDirName={pf}\example
DefaultGroupName=example
OutputDir=F:\Test
OutputBaseFilename=setup
Compression=lzma
SolidCompression=yes
Uninstallable=yes
UninstallDisplayName=卸载 {#MyAppName}

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

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

[Files]
Source: "C:\Users\qinbo\Desktop\GMP\KnowledgeManagement.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Users\qinbo\Desktop\GMP*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "C:\Users\qinbo\Desktop\GMP\plugins\instsall.bat"; DestDir: "{app}"; Flags: ignoreversion
; 注意: 不要在任何共享系统文件上使用“Flags: ignoreversion”

[Icons]
Name: "{group}\example"; Filename: "{app}\KnowledgeManagement.exe"
Name: "{commondesktop}\example"; Filename: "{app}\KnowledgeManagement.exe"; Tasks: desktopicon

[Run]
Filename: "{app}\KnowledgeManagement.exe"; Description: "{cm:LaunchProgram,example}"; Flags: nowait postinstall skipifsilent
Filename: "C:\Users\qinbo\Desktop\GMP\plugins\instsall.bat"; Flags: nowait

[Registry]
Root: HKLM; Subkey:"Software\Test\example";ValueType:dword;ValueName:config;ValueData:10;Flags:uninsdeletevalue
[Code]
//删除所有配置文件以达到干净卸载的目的
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);

begin

if CurUninstallStep = usUninstall then

//if MsgBox('您是否要删除用户配置信息?', mbConfirmation, MB_YESNO) = IDYES then

//删除 {app} 文件夹及其中所有文件

DelTree(ExpandConstant('{app}'), True, True, True);

end;

//把安装位置在安装的时候写进注册表中,更新安装的时候你读取注册表中已保存的路径
procedure InitializeWizard();
var ResultStr: String;
ResultCode: Integer;
begin
if RegQueryStringValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall{5EF80699-C8CA-464E-94A7-0A87A8841A22}}_is1', 'UninstallString', ResultStr) then
begin
ResultStr := RemoveQuotes(ResultStr);
Exec(ResultStr, '', '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode);
end;
end;

//检查版本号
function GetInstalledVersion(): String;
var
InstalledVersion: String;
begin
InstalledVersion :='';
RegQueryStringValue(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion', 'Installed version', InstalledVersion);
Result := InstalledVersion;
end

;//安装、卸载前检查关闭**进程

var
HasRun:HWND;

function InitializeSetup():Boolean;
begin

//检测运行应用程序
Result := true;
HasRun := FindWindowByWindowName('我的应用');
while HasRun<>0 do
begin
if MsgBox('安装程序检测到你的应用程序正在运行。' #13#13 '您必须先关闭它然后单击“是”继续安装,或按“否”退出!', mbConfirmation, MB_YESNO) = idNO then
begin
Result := false;
HasRun := 0;
end
else
begin
Result := true;
HasRun := FindWindowByWindowName('Gloud Arena');
end;
end;

end;

function InitializeUninstall(): Boolean;
begin
HasRun := FindWindowByWindowName('我的应用');
if HasRun<>0 then
begin
MsgBox('卸载程序检测到你的应用程序正在运行。' #13#13 '请先退出你的应用程序,然后再进行卸载!', mbError, MB_OK);
Result := false;
end
else
Result := true;
end;

[/code]

  • 写回答

1条回答 默认 最新

  • shen_wei 2016-12-07 02:31
    关注

    begin
    ResultStr := RemoveQuotes(ResultStr);
    Exec(ResultStr, '', '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode);
    end;

      begin
         ResultStr :=RemoveQuotes(ResultStr);
         if MsgBox('You have to install the software, whether to remove the old version?', mbConfirmation, MB_YESNO) = IDYES 
         then 
         Exec(ResultStr,'/VERYSILENT','',SW_SHOWNORMAL, ewWaitUntilTerminated,ResultCode);
         Sleep(2000);
         end;
    
    评论

报告相同问题?

悬赏问题

  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
  • ¥15 安装svn网络有问题怎么办
  • ¥15 vue2登录调用后端接口如何实现