如何检查INNOSETUP中的注册表值 [英] How to check the registry value in INNOSETUP
本文介绍了如何检查INNOSETUP中的注册表值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Root:HKLM;子键:SOFTWARE\xxx\yyy; ValueType:string; ValueName:KEYNAME; ValueData:{olddata}; C:\ x\y\z.dll
我在inno设置中使用这行代码来打开注册表路径并在现有数据的enf处添加a.dll。如何检查注册表值是否具有我想要添加的dll名称。
我尝试了什么:
i尝试使用if和comparetext的组合但没有成功
Root: HKLM; Subkey: "SOFTWARE\xxx\yyy"; ValueType: string ; ValueName: "KEYNAME"; ValueData: "{olddata};C:\x\y\z.dll
I am using this line of code in inno setup to open the registry path and add a.dll at the enf of the existing data. How to check if the registry value has the dll name which i want to add.
What I have tried:
i have tried using the combination of if and comparetext but didn't succeed
推荐答案
如果要检查密钥是否存在并读取当前值,则必须使用 Pascal Scripting [ ^ ]在 [Code] [ ^ ]部分。但是,这个请求您熟悉Inno Setup使用的Pascal脚本。
从注册表中读取字符串值的函数是RegQueryStringValue [ ^ ]。然后,您可以使用Pos
字符串函数来检查该值是否包含特定子字符串或使用CompareText
/CompareStr
比较完整的字符串。
未经测试的例子:
If you want to check if the key exists and read the current value, you must use Pascal Scripting[^] in the [Code][^] section. However, this requires that you become familiar with the Pascal scripting used by Inno Setup.
The function to read a string value from the registry is RegQueryStringValue[^]. You can then for example use thePos
string function to check if the value contains a specific substring or useCompareText
/CompareStr
to compare complete strings.
Untested example:
var
Value, LowerValue: String;
Search: Integer;
begin
if RegQueryStringValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\xxx\yyy', 'KEYNAME', Value) then
begin
LowerValue := Lowercase(Value);
Search := Pos('c:\x\y\z.dll', LowerValue);
if (Search = 0) then
begin
Value := Value + ';C:\x\y\z.dll';
RegWriteStringValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\xxx\yyy', 'KEYNAME', Value);
end;
else
RegWriteStringValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\xxx\yyy', 'KEYNAME', 'C:\x\y\z.dll');
end;
end;
这篇关于如何检查INNOSETUP中的注册表值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文