查看完整版本: [-- 【已解决】Inno Setup怎么自动选择从注册表获取软件目录所在盘? --]

汉化新世纪论坛 -> 安装与补丁 -> 【已解决】Inno Setup怎么自动选择从注册表获取软件目录所在盘? [打印本页] 登录 -> 注册 -> 回复主题 -> 发表主题

2015 2016-09-26 21:39

【已解决】Inno Setup怎么自动选择从注册表获取软件目录所在盘?

我以前用利用“注册表卸载信息方法”会直接读取到实际安装路径的,但现在不需要读取到目录,只需要读取到那个盘可以了,用注册表可以实现吗?


DefaultDirName={reg:HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Adobe Premiere 6.5,InstallLocation}


其中InstallLocation的值是d:\abc,如果最终想得到的路径是d:该如何实现呢?




wanfu 2016-09-28 11:24
请参考以下脚本(我也是参考 Inno Setup 帮助现学的):

[Setup]
AppName=My Program
AppVersion=1.5
;从代码中获取原程序的安装目录,好处是如果获取的目录为空,可以定义一个默认的
DefaultDirName={code:MyConst}\My Program 
DefaultGroupName=My Program
UninstallDisplayIcon={app}\MyProg.exe
Compression=lzma2
SolidCompression=yes
OutputDir=userdocs:Inno Setup Examples Output
; "ArchitecturesAllowed=x64" specifies that Setup cannot run on
; anything but x64.
ArchitecturesAllowed=x64
; "ArchitecturesInstallIn64BitMode=x64" requests that the install be
; done in "64-bit mode" on x64, meaning it should use the native
; 64-bit Program Files directory and the 64-bit view of the registry.
ArchitecturesInstallIn64BitMode=x64

[Files]
Source: "MyProg-x64.exe"; DestDir: "{app}"; DestName: "MyProg.exe"
Source: "MyProg.chm"; DestDir: "{app}"
Source: "Readme.txt"; DestDir: "{app}"; Flags: isreadme

[Icons]
Name: "{group}\My Program"; Filename: "{app}\MyProg.exe"

[Code]
Function MyConst(Path: String): String;
begin
  Result := ExpandConstant('{pf}');  //预定义一个安装根目录
  RegQueryStringValue(HKLM,'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft Security Client','InstallLocation',Path);
  if Path <> '' then
     Result := ExtractFileDrive(Path);   //提取根目录
end;


2015 2016-09-28 19:43
感谢版主专业回答!有点看不懂可以简化一些吗?可能是我不会表达,我想将一个补丁发到Adobe Premiere 6.5所在盘,不需要发到Adobe Premiere 6.5文件夹内的(也就是说abc.sim补丁如何发到同一个盘,不需要发到文件夹内)。如下图:

[attachment=33342]

chenmy 2016-09-29 00:41
使用 {drive: Path } 变量,直接得到盘符。

2015 2016-09-29 21:43
chenmy:使用 {drive: Path } 变量,直接得到盘符。 (2016-09-29 00:41) 

谢谢老师!!!那具体怎样写,请教下。


查看完整版本: [-- 【已解决】Inno Setup怎么自动选择从注册表获取软件目录所在盘? --] [-- top --]



Powered by phpwind v8.7 Code ©2003-2011 phpwind
Time 0.013427 second(s),query:3 Gzip disabled