ExpandConstantfunction似乎不能在Windows 7上工作

ExpandConstantfunction似乎不能在Windows 7上工作,第1张

概述ExpandConstantfunction似乎不能在Windows 7上工作

我正在尝试使用此函数来在运行时翻译{app}variables。 它适用于windows 2008(64位),但不适用于windows 7(64位)。

这是我使用的代码:

[Registry] Root: HKLM; Subkey: "SYstemCurrentControlSetControlSession ManagerEnvironment"; ValueType: expandsz; Valuename: "Path"; ValueData: "{olddata};{app}"; Check: ExpandConstant(NeedsAddpath('{app}')) function NeedsAddpath(Param: string): boolean; var OrigPath: string; begin if not RegqueryStringValue(HKEY_LOCAL_MACHINE,'SYstemCurrentControlSetControlSession ManagerEnvironment','Path',OrigPath) then begin Result := True; exit; end; // look for the path with leading and trailing semicolon // Pos() returns 0 if not found Result := Pos(';' + UpperCase(Param) + ';',';' + UpperCase(OrigPath) + ';') = 0; if Result = True then Result := Pos(';' + UpperCase(Param) + ';',';' + UpperCase(OrigPath) + ';') = 0; end;

你知道原因吗?

谢谢!

避免Inno安装程序中的“无法展开shell文件夹常量userdocs”错误

如何在没有在Inno Setup中打开新窗口的情况下运行CMD命令

如何使用inno-setup进行检查,如果一个进程在windows 2008 R2 64位上运行?

Inno Setup:控制面板图标不显示

recursionsearchregistry

Inno – 防止registry键被redirect到Wow6432Node

检查Inno安装程序中是否存在快捷方式

为什么我的Delphi 6程序仅在less数windows 7系统(InnoSetup)上安装时触发pipe理权限请求?

从虚拟化windowsregistry中读取密钥

确定Inno Setup中的windows版本

您的代码在任何 *** 作系统上都无法正常工作,因为您的 *** 作顺序错误。 (如果你认为它在Win2008上工作,这只是意味着你没有测试你的想法,或者错误地解释了结果。)

你的代码的主要问题是你调用Check函数的方式:

Check: ExpandConstant(NeedsAddpath('{app}'))

您正在扩展NeedsAppPath的结果,当NeedsAppPath的代码显然预期{app}在参数传入时已经被扩展。

将其更改为:

Check: NeedsAppPath(ExpandConstant('{app}'))

(事实上​​,上面的代码甚至不应该编译,因为Check函数需要返回布尔值,而ExpandConstant不会这么做,所以你显然不会测试你的想法。

类似下面的东西可能会更好,但是这并不能解释为什么原始版本不能工作。 有一件事是肯定的,原来的代码传递给Check参数字符串作为结果,而不是布尔值,基本上是错误的,但它不能解释为什么它在windows 2008上工作:

[Setup] Appname=My Program AppVersion=1.5 DefaultDirname={pf}My Program #define KeyPath "SYstemCurrentControlSetControlSession ManagerEnvironment" [Registry] Root: HKLM; Subkey: "{#KeyPath}"; ValueType: expandsz; Valuename: "Path"; ValueData: "{olddata};{app}"; Check: NeedsAddpath [Code] function NeedsAddpath: Boolean; var AppPath: string; OrigPath: string; begin Result := True; if RegqueryStringValue(HKEY_LOCAL_MACHINE,'{#KeyPath}',OrigPath) then begin AppPath := ExpandConstant('{app}'); Result := Pos(';' + UpperCase(AppPath) + ';',';' + UpperCase(OrigPath) + ';') = 0; if Result then Result := Pos(';' + UpperCase(AppPath) + ';',';' + UpperCase(OrigPath) + ';') = 0; end; end;

总结

以上是内存溢出为你收集整理的ExpandConstantfunction似乎不能在Windows 7上工作全部内容,希望文章能够帮你解决ExpandConstantfunction似乎不能在Windows 7上工作所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/1270439.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-08
下一篇 2022-06-08

发表评论

登录后才能评论

评论列表(0条)

保存