论坛风格切换切换到宽版
  • 3588阅读
  • 4回复

Inno Setup 访问注册表的问题 [复制链接]

上一主题 下一主题
离线weihua2000
 

发帖
3
金钱
30
威望
3
只看楼主 倒序阅读 0 发表于: 2014-03-25
昨日在研究安装补丁包, 借用了虎版的代码:

[Code]
function InitializeSetup(): Boolean;
var
sPath: String;
begin
Result := false;
if RegQueryStringValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Altair HyperWorks Master Installer 12.0 (Local 64-bit)', 'InstallLocation', sPath) then
if sPath > '' then
Result:= true;
end;
目的是找到相关的注册表信息,实现安装是自动添加目录功能, 可返回值一直是空, 其他比如.net注册表信息等都用相同的方法取到, 就这个信息不行,环境win7 x64

相关注册表信息导出的纪录如下:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Altair HyperWorks Master Installer 12.0 (Local 64-bit)]
"DisplayName"="Altair HyperWorks Master Installer 12.0 (Local 64-bit)"
"UninstallString"="\"C:\\Program Files\\Altair\\12.0\\uninstalls\\Uninstall_HyperWorksMasterInstaller12.0\\Uninstall_HyperWorksMasterInstaller12.0.exe\""
"Publisher"="Altair Engineering, Inc."
"URLInfoAbout"="http://www.altair.com/Default.aspx"
"URLUpdateInfo"="http://www.altairhyperworks.com/Default.aspx"
"Contact"="info@altair.com"
"ProductID"="4d453f07-b654-4b47-928a-d37a6c1bdbdc"
"InstallLocation"="C:\\Program Files\\Altair\\12.0"
"InstallDate"="Mon Feb 24 17:02:01 CST 2014"
"HelpLink"="http://www.altairhyperworks.com/ClientCenterHWSupportProduct.aspx?top_nav_str=1"
"DisplayVersion"="12.0"
"Comments"="Built upon a foundation of design optimization, performance data management and process automation, HyperWorks is an enterprise simulation solution for rapid design exploration and decision-making. As the most comprehensive, open-architecture CAE solution in the industry, HyperWorks includes best-in-class modeling, analysis, visualization and data management solutions for linear, nonlinear, structural optimization, fluid-structure interaction, and multi-body dynamics applications.
"
"DisplayIcon"="C:\\Program Files\\Altair\\12.0\\icons\\hw-add-remove.ico"
"ShortcutsFolderPath"="C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\Altair HyperWorks 12.0 (64-bit)"

请大家指点一二,  在此谢过了
离线wanfu

发帖
2728
金钱
12110
威望
1211
只看该作者 1 发表于: 2014-03-25
if sPath > '' then
上面这句是不是错了?应该为 if sPath <> '' then 吧
请改成下列试试看:
Result := false;
RegQueryStringValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Altair HyperWorks Master Installer 12.0 (Local 64-bit)', 'InstallLocation', sPath)
if sPath <> '' then
Result:= true;

离线weihua2000

发帖
3
金钱
30
威望
3
只看该作者 2 发表于: 2014-03-25
多谢指导, 但path里面的内容还是为空, 我想问下, 是我的系统的原因取不出注册表unistall信息, 还是和360等杀毒程序作怪, 实在是想不出原因了.
离线gnatix

发帖
7696
金钱
-8279
威望
-828
只看该作者 3 发表于: 2014-03-25
建议你换一个原版的  INNO 试试看。
离线weihua2000

发帖
3
金钱
30
威望
3
只看该作者 4 发表于: 2014-03-26
我又重新下载了一个unicode版本的, 就能取到了, 看来可能是因为内码的问题.