开发者

Inno Setup StringChangeEx Failure

I'm using an Inno Setup script to install my 32- and 64-bit DLLs in a 64-bit install. I can get the 64-bit path from a registry setting, but the 32-bit path is missing does not exist. However, I know that the path's 'tail' is constant, just the head needs to be modified. Ie,

64-bit (from registry) = c:\Program Files\My Application\Bin
32-bit (derived)       = c:\Program Files (x86)\My Application\Bin

So what I do is swap out the 64-bit program file path with the 32-bit one. I do this easily with StringChangeEx:

RegQueryStringValue(HKLM, 'SOFTWARE\My Application', 'RootDir', sPath)
if IsWin64() then
  StringChangeEx(sPath, ExpandConstant('{pf}'), ExpandConstant('{pf32}'), False);

sPath is returned with my 32-bit path. This works great on most systems, but it seems that sometimes StringChangeEx does not swap out 'C:\Program Files' for 'C:\Program Files (x86)'. I have verified (using MsgBox's) that the {pf} and {pf32} constants are what I think they are. Casing is the same and there are no leading/trailing spaces. I开发者_运维问答t just seems that on some systems, the function doesn't work.

I'm using the latest version of InnoSetup (10/2010). The web site doesn't mention any problems with this function. Has anyone else seen this and/or have any ideas on what it could be?


I threw together this little script and using 5.4.0 (10/2010 release), it worked:

; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{AE1A6BBB-7582-43AA-85F5-C7F984D1A68B}
AppName=My Program
AppVersion=1.5
;AppVerName=My Program 1.5
AppPublisher=My Company, Inc.
AppPublisherURL=http://www.example.com/
AppSupportURL=http://www.example.com/
AppUpdatesURL=http://www.example.com/
DefaultDirName={pf}\My Program
DefaultGroupName=My Program
OutputBaseFilename=setup
Compression=lzma
SolidCompression=yes

[Code]
function InitializeSetup(): Boolean;

var
sPath : string;

begin
sPath := ExpandConstant('{pf}') + '\mypath';
if IsWin64() then
  StringChangeEx(sPath, ExpandConstant('{pf}'), ExpandConstant('{pf32}'), False);
 MsgBox(sPath, mbInformation, MB_OK);
result := true;

end;

Does my script work or fail for you?
Is sPath correct before your call to StringChangeEx?

I would suggest the /LOG option but code isn't logged automatically. You would need to add Log(const S: String) calls.


Turns out that the registry entry sometimes had a lower-case drive letter. I changed the code to:

RegQueryStringValue(HKLM, 'SOFTWARE\My Application', 'RootDir', sPath)
sPath := Lowercase(sPath);
if IsWin64() then
  StringChangeEx(sPath, Lowercase(ExpandConstant('{pf}')), Lowercase(ExpandConstant('{pf32}')), False)

I had assumed the registry entry was not the problem, but not quite so.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜