PDA

View Full Version : Registry Path Confusion


3DTrains
11-22-2007, 09:49 AM
Changing from SUF 5 to v7 (trial), I'm having a tough time getting my head around the use of variables in locating an existing path on a user's sytem. The following is what I've tried thus far (in the Actions > On Startup box):

RegVar = Registry.GetValue(HKEY_LOCAL_MACHINE, "Software\\My Application", "EXE Path", true);
if RegVar ~= "" then
SessionVar.Set("%AppFolder%", RegVar);
end

and...

RegVar = Registry.GetValue(HKEY_LOCAL_MACHINE, "Software\\My Application", "EXE Path", true);
result = Application.GetLastError();
SessionVar.Set("%AppFolder%", RegVar);
RegVar = SessionVar.Expand("%AppFolder%");

Session Variables:

Folder Defaults
%RegVar% (entered in the right-side pane on the %AppFolder% line)

When I run the resulting setup, the first code example returns "%RegVar%" into the path dialog, instead of the path taken from the registry. The second code example returns an empty field for the directory to be installed to. This was all fairly straight forward in SUF v5 and it worked fine, but I'm a bit lost in SUF v7.

Brett
11-22-2007, 09:56 AM
If RegVar is meant to be a session variable (one that is expanded in text) then you need to change your last line to:

SessionVar.Set("%RegVar%", SessionVar.Expand("%AppFolder%"));

I would suggest that you read Chapter 5 o fthe User's Guide to get a more clear understanding of Session Variables.

3DTrains
11-22-2007, 10:20 AM
Thank you, but I still get a literal "%ReVar%" in the path dialog after the setup has been compiled:

RegVar = Registry.GetValue(HKEY_LOCAL_MACHINE, "Software\My Application", "EXE Path", true);
SessionVar.Set("%RegVar%", SessionVar.Expand("%AppFolder%"));

I realize I'm missing something, but clueless as to what.

3DTrains
11-23-2007, 12:03 PM
Missed the double '\\' in the path, and finally got it working. :p

RegVar = Registry.GetValue(HKEY_LOCAL_MACHINE, "Software\\My Application", "EXE Path", true);
SessionVar.Set("%AppFolder%", RegVar);