论坛风格切换切换到宽版
  • 5412阅读
  • 7回复

【已解决】两个补丁怎么将一个补丁发到软件所在目录,另一个发到上级目 [复制链接]

上一主题 下一主题
离线2015
 

发帖
48
金钱
459
威望
46
只看楼主 倒序阅读 0 发表于: 2016-10-03
请教大家,注意红色部分,aaa文件夹发到软件所在目录内的(这个我会了),那怎样将kara.lic补丁发到软件所在目录的上级目录,有朋友说使用 {drive: Path } 变量,直接得到盘符。但我看了十多天说明书还是不会写,所以请教大家了。

AppName=Adobe Premiere 6.5 Patch
AppVerName=Adobe Premiere 4.0.0.58版本
AppPublisher=Adobe Premiere 6.5
DefaultDirName={reg:HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Adobe Premiere 6.5,InstallLocation}
OutputDir=C:\Users\Public\Desktop
OutputBaseFilename=Patch
SolidCompression=yes
Compression=lzma/ultra64
//此压缩为7z极限压缩算法
DisableDirPage=no
DisableProgramGroupPage=yes
DirExistsWarning=no
Uninstallable=no
WizardImageFile=C:\Users\Administrator\Desktop\Office2007Gray.bmp
SetupIconFile=C:\Users\Administrator\Desktop\dd.ico
RestartIfNeededByRun=no
VersionInfoVersion=2016.10.2
VersionInfoTextVersion=2016.10.2
ShowLanguageDialog=auto
;安装密码
;版本号
DisableReadyMemo=yes
;如果设置为 yes,无显示准备安装向导页
[Files]
; Add the Visual Style resource contains resources used for skinning,
; you can also use Microsoft Visual Styles (*.msstyles) resources.
Source: {#ExtendDir}\ISSkin\Styles\Office2007.cjstyles; DestDir: {tmp}; Flags: dontcopy
Source: "C:\Users\Administrator\Desktop\aaa\*"; DestDir: "{app}"; Flags: overwritereadonly ignoreversion
Source: "C:\Users\Administrator\Desktop\kara.lic";DestDir: "{app}"; Flags: overwritereadonly ignoreversion



本帖提到的人: @wanfu
离线wanfu

发帖
2734
金钱
12170
威望
1217
只看该作者 1 发表于: 2016-10-03
{drive: Path } 只是获取路径中的磁盘盘符,如果你要获取原程序的安装目录的父目录,这个命令是没有用的,需要自己写个截取子字符串函数。你试试以下脚本:

[Setup]
AppName=Adobe Premiere 6.5 Patch
AppVerName=Adobe Premiere 4.0.0.58版本
AppPublisher=Adobe Premiere 6.5
;DefaultDirName={reg:HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Adobe Premiere 6.5,InstallLocation}
;默认安装目录改为从代码段获取,以便在注册表值为空时可以做更多的处理,
'如给出提示并终止安装,或使用默认目录(示例脚本为默认目录)

DefaultDirName={code:MyConst}
OutputDir=C:\Users\Public\Desktop
OutputBaseFilename=Patch
SolidCompression=yes
Compression=lzma/ultra64
//此压缩为7z极限压缩算法
DisableDirPage=no
DisableProgramGroupPage=yes
DirExistsWarning=no
Uninstallable=no
WizardImageFile=C:\Users\Administrator\Desktop\Office2007Gray.bmp
SetupIconFile=C:\Users\Administrator\Desktop\dd.ico
RestartIfNeededByRun=no
VersionInfoVersion=2016.10.2
VersionInfoTextVersion=2016.10.2
ShowLanguageDialog=auto
;安装密码
;版本号
DisableReadyMemo=yes
;如果设置为 yes,无显示准备安装向导页
[Files]
; Add the Visual Style resource contains resources used for skinning,
; you can also use Microsoft Visual Styles (*.msstyles) resources.
Source: {#ExtendDir}\ISSkin\Styles\Office2007.cjstyles; DestDir: {tmp}; Flags: dontcopy
Source: "C:\Users\Administrator\Desktop\aaa\*"; DestDir: "{app}"; Flags: overwritereadonly ignoreversion
;Source: "C:\Users\Administrator\Desktop\kara.lic";DestDir: "{app}"; Flags: overwritereadonly ignoreversion
;修改为目标目录从 Code 段获取,即为 App 目录的父目录
Source: "C:\Users\Administrator\Desktop\kara.lic";DestDir: "{code:ParentPath}"; Flags: overwritereadonly ignoreversion

[Code]
//获取注册表中的安装目录
Function MyConst(Path: String): String;
begin
  Result := ExpandConstant('{pf}') + ‘Adobe Premiere 6.5’;  //预定义一个默认安装目录
  RegQueryStringValue(HKLM,‘SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Adobe Premiere 6.5','InstallLocation',Path);
  if Path <> '' then
     //Result := ExtractFileDrive(path);   //提取根目录
     Result := path;
end;

//获取父目录函数
Function ParentPath(Path: String): String;
var
  i,k: Integer;
  substr: string;
begin
  //传入的 Path 参数为空的话,赋值为 App 值
  if Path = '' then Path := ExpandConstant('{app}');
  substr := '\';  //定义要被查找的字符
  Result := Path;  //备份 Path,以避免截取子字符串后 Path 值改变
  //如果 Result 最后一个字符是 substr 的话,删除最后一个字符
  if copy(Result,Length(Result),1) = substr then begin
     Result := copy(Result,1,Length(Result) - 1);
  end;
  //获取 substr 在 Result  中的首个位置值
  i := Pos(substr,Result);
  //循环截取子字符串,并获取 substr 在子字符串 Result  中的位置值,记录 substr 在原字符串 Path 中的最后位置值
  while i > 0 do
     begin
     k := k + i;   //记录每次截取和查找后 substr 在原字符串 Path 中的位置值
     Result := Copy(Result,i + 1,Length(Result) - i);  //截取找到位置 i + 1 到 Result 最后字符的子字符串  
     i := Pos(substr,Result);   //再次获取 substr 在新 Result  中的首个位置值
  end;
  //如果找到 substr 值,获取 path 中第一个字符到最后 substr 位置为止的子字符串
  if k > 0 then Result := Copy(Path,1,k);
end;

//在选择安装目录页中单击下一步时显示获取父目录函数的测试结果,实际使用时请删除
function NextButtonClick(CurPageID : Integer): Boolean;  
begin
  Result := true;
  if CurPageID = wpSelectDir then begin
     msgbox(ExpandConstant('{app}'), mbInformation, MB_OK);
     msgbox(ParentPath(ExpandConstant('{app}')), mbInformation, MB_OK);
  end;
end;
离线2015

发帖
48
金钱
459
威望
46
只看该作者 2 发表于: 2016-10-04
回 1楼(wanfu) 的帖子
wanfu:{drive: Path } 只是获取路径中的磁盘盘符,如果你要获取原程序的安装目录的父目录,这个命令是没有用的,需要自己写个截取子字符串函数。你试试以下脚本:[Setup]AppName=Adobe Premiere 6.5 PatchAppVe .. (2016-10-03 21:22)

wanfu版主太神了,可以了,非常感谢你的解答!对我的帮助,我会记得你对我的好的!

嗯,还想问下,如果DefaultDirName没有加上Wow6432Node会对32位和64位有影响吗?

还有,DefaultDirName={code:MyConst}改成下面这些才可以的,这样会有影响吗?

DefaultDirName={reg:HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Adobe Premiere 6.5,InstallLocation}
本帖提到的人: @wanfu
离线wanfu

发帖
2734
金钱
12170
威望
1217
只看该作者 3 发表于: 2016-10-04
回 2楼(2015) 的帖子
2015:wanfu版主太神了,可以了,非常感谢你的解答!对我的帮助,我会记得你对我的好的! 嗯,还想问下,如果DefaultDirName没有加上Wow6432Node会对32位和64位有影响吗? ....... (2016-10-04 00:01)

你的安装程序的 DefaultDirName 是读取注册表的,为了兼容 32/64,最好不要在注册表路径中加上 Wow6432Node 节点。

DefaultDirName={code:MyConst} 为什么要改成你写的那样?二楼给你的脚本没有用?至于有什么不同,红色备注中已经说明了,你难道没有看到。


离线2015

发帖
48
金钱
459
威望
46
只看该作者 4 发表于: 2016-10-04
回 3楼(wanfu) 的帖子
wanfu:你的安装程序的 DefaultDirName 是读取注册表的,为了兼容 32/64,最好不要在注册表路径中加上 Wow6432Node 节点。 DefaultDirName={code:MyConst} 为什么要改成你写的那样?二楼给你的脚本没有用?至于有什 .. (2016-10-04 17:27)

我想这样的,当注册表值为空时就证明没有安装原程序,然后在路径哪里弹出没有安装提示,版主见笑了,因为我不知道“先检验原程序是否安装”怎么写,只能这样了。不知道这样会有影响吗?

本帖提到的人: @wanfu
离线wanfu

发帖
2734
金钱
12170
威望
1217
只看该作者 5 发表于: 2016-10-04
检测是否已经安装原程序很简单,加入下列代码即可:

//在安装程序初始化时检测原程序是否已安装,未安装时给出提示并退出安装
Function InitializeSetup():boolean;
begin
    Result:= true;
    if not RegKeyExists(HKLM,‘SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Adobe Premiere 6.5’) then begin
       MsgBox('Adobe Premiere 6.5 未安装,请先行安装!', mbInformation, MB_OK);
       Result := False;
     end;
end;
离线2015

发帖
48
金钱
459
威望
46
只看该作者 6 发表于: 2016-10-04
回 5楼(wanfu) 的帖子
wanfu:检测是否已经安装原程序很简单,加入下列代码即可://在安装程序初始化时检测原程序是否已安装,未安装时给出提示并退出安装Function InitializeSetup():boolean;begin....... (2016-10-04 21:15) 

太感谢wanfu斑竹了!真的可以啦。
离线chenmy

发帖
2863
金钱
60
威望
6
只看该作者 7 发表于: 2016-10-06
问题解决了就好,但我记得你原先是说想要得到目标程序所在的根目录的啊。
我是中国人·最爱是中文!