如果单用安装与卸载检测文件代码一切正常,加了安装前卸载老版本代码后只有安装与卸载检测文件代码可以用
跟上次你帮我的那个代码一样,只是这次是根据ISTask.dll插件了
以下是我的代码:
; 脚本用 Inno Setup 脚本向导 生成。
; 查阅文档获取创建 INNO SETUP 脚本文件的详细资料!
#define MyAppName "我的程序"
#define MyAppVersion "2.0.1.1"
#define MyAppPublisher "汉化新世纪"
#define MyAppURL "http://bbs.hanzify.org"
#define MyAppExeName "OneKey.exe"
[Setup]
; 注意: AppId 的值是唯一识别这个程序的标志。
; 不要在其他程序中使用相同的 AppId 值。
; (在编译器中点击菜单“工具 -> 产生 GUID”可以产生一个新的 GUID)
AppId={{我的程序}
AppName=我的程序
AppVersion=1.5
;AppVerName=我的程序 1.5
AppPublisher=我的公司
AppPublisherURL=http://www.example.com/
AppSupportURL=http://www.example.com/
AppUpdatesURL=http://www.example.com/
DefaultDirName={pf}\我的程序
DefaultGroupName=我的程序
OutputDir=E:\本地下载\inno编译目录
OutputBaseFilename=setup
Compression=lzma
SolidCompression=yes
[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';
procedure InitializeWizard();
var
ResultStr: String;
ResultCode: Integer;
begin
if RegQueryStringValue(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{我的程序}_is1','UninstallString', ResultStr) then
//_is1 注册信息
begin
ResultStr := RemoveQuotes(ResultStr);
Exec(ResultStr, '', '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode);
end;
end;
function InitializeSetup(): Boolean;
begin
Result:= true;
if RunTask1('OneKey.exe', false) then
if MsgBox('安装程序检测到 OneKey.exe 正在运行!'#13''#13'单击“是”按钮关闭程序并继续安装!'#13''#13'单击“否”按钮则退出安装程序!',mbConfirmation, MB_OKCANCEL) = IDOK then
KillTask1('OneKey.tmp')
else begin
Result :=false;
end;
end;
function InitializeUninstall(): Boolean;
begin
Result:= true;
if RunTask('OneKey.exe', false) then
if MsgBox('卸载程序检测到 OneKey.exe 正在运行!'#13''#13'单击“是”按钮关闭程序并进行卸载!'#13''#13'单击“否”按钮则退出安装程序!',mbConfirmation, MB_OKCANCEL) = IDOK then
KillTask('OneKey.tmp')
else begin
Result :=false;
end;
UnloadDll(ExpandConstant('{app}\ISTask.dll'))
end;
[Languages]
Name: "default"; MessagesFile: "compiler:Default.isl"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
[Files]
Source: "E:\本地下载\inno编译目录\{app}\ISTask.dll"; DestDir: "{app}"; Flags: solidbreak
Source: "E:\本地下载\inno编译目录\{app}\OneKey.exe"; DestDir: "{app}"; Flags: ignoreversion
; 注意: 不要在任何共享的系统文件使用 "Flags: ignoreversion"
[Icons]
Name: "{group}\我的程序"; Filename: "{app}\OneKey.exe"
Name: "{group}\{cm:UninstallProgram,我的程序}"; Filename: "{uninstallexe}"
Name: "{commondesktop}\我的程序"; Filename: "{app}\OneKey.exe"; Tasks: desktopicon
[Run]
Filename: "{app}\OneKey.exe"; Description: "{cm:LaunchProgram,我的程序}"; Flags: nowait postinstall skipifsilent