杉宫竹苑工作室

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 2294|回复: 0

Inno Setup怎么自动选择从注册表获取软件目录所在盘

[复制链接]
发表于 2017-1-9 16:32:58 | 显示全部楼层 |阅读模式

正式会员享受无限制浏览网站功能和高速网盘下载,赶快加入本站吧!

您需要 登录 才可以下载或查看,没有账号?立即注册

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

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

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

  24. [Code]
  25. Function MyConst(Path: String): String;
  26. begin
  27.   Result := ExpandConstant('{pf}');  //预定义一个安装根目录
  28.   RegQueryStringValue(HKLM,'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft Security Client','InstallLocation',Path);
  29.   if Path <> '' then
  30.      Result := ExtractFileDrive(Path);   //提取根目录
  31. end;
复制代码


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|手机版|Archiver|SgzyStudio

GMT+8, 2024-5-16 04:57 , Processed in 0.116425 second(s), 22 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表