PDA

View Full Version : Assigning value from registry


Sheritlw
09-28-2004, 11:42 PM
I created a custom session variable named %InstallDirectory%, and assigned a default path to this variable (%ProgramFilesFolder%\%ProductName%).

Then in the Start Up action, I try/want to check and see if the value already exists in the registry and then if it does, assign it to the Session Variable.
After several failed attempts, I thought I would see if anyone can tell me what I am doing wrong.

SubKey = ".HKEY_CURRENT_USER\\Software\\" .. SessionVar.Expand("%CompanyName%") .. "\\" .. SessionVar.Expand("%RegistryName%");
Value = "UserFileInstall";
InstallDirectory = Registry.GetValue(HKEY_LOCAL_MACHINE, SubKey, Value, true);

if "InstallDirectory" ~= "" then
SessionVar.Set("%InstallDirectory%", InstallDirectory)
result = Dialog.Message("Notice", SessionVar.Expand("%InstallDirectory%"), MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
end

JXBURNS
09-29-2004, 04:11 AM
You have gone overboard with your SubKey definition as the REGISTRY.GETVALUE command already refers to the LocalMachine entry so you are defining twice.

Should be something like:

SubKey = SessionVar.Expand("%CompanyName%") + "\\" + SessionVar.Expand("%RegistryName%");

[Don't have SUF7 in front of me right now so above not may not be quite right syntax.]

Also your GETVALUE refers to HKLM then in your SUBKEY you refer to CurrentUser - are you sure you meant this?

Perhaps you were trying to get this:

InstallDirectory = Registry.GetValue(HKEY_CURRENT_USER, SubKey, Value, true);

John