开发者

Getting a file version number in the [Registry] section

I am creating an installer for a visual studio project using inno setup. I am getting an error for

"Parameter ValueData has invalid value"

for this code:

[Code]
function GetVersion(AppVersion: String): String;
var
  Version: String;
  CharIndex: integer;
  c: char;
begin  
for CharIndex := 1 to Length(AppVersion) do begin
    c := AppVersion[CharIndex];
    if (c <> '.') then
    Version开发者_JS百科 := Version + c;
end;
Result := Version;
end;

[Registry]
Root: HKCU; Subkey: "MyCompany\Product"; ValueType: DWORD ; ValueName: "Version" ;     ValueData: GetVersion({#MyAppVersion}); Flags: uninsdeletekey;

I have versioning like this "1.0.0.3, 1.0.0.4, etc". So this program removes . and concatenates all of them to form a number and should pass back to write to registry. So, I can check this registry value and uninstall or update the previous version. I heard someone saying inno would upgrade automcatically, but I create icons with their name with version number. Thanks in advance.


The problem you are seeing is because to call a function as a parameter in the main sections of InnoSetup, you need to use the {code:} construct.
Here's an example that worked for me:

[Registry]
Root: HKCU; Subkey: "Software\MyCompany\Product"; ValueType: DWORD ; ValueName: "Version" ;     ValueData: {code:GetVersion|{#MyAppVersion}}; Flags: uninsdeletekey;


As @Ken White said, your constant is "broken" which makes the entire string literal invalid. Even then, you ValueData is still just GetVersion(WhateverMyAppVersionIs) instead if the result of that function. For that, use a {code:} constant to call GetVersion.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜