PDA

View Full Version : Get %AppFolder% from registry


FrostByte
08-24-2009, 11:47 AM
Hi all,

I'm working on an installer for an expansion module.

The installer should determine if the main application is already installed on the system by searching for a registry value in:

"HKEY_LOCAL_MACHINE\\Software\\My Product"

The value in question is stored in "Installed Path"

-------------------

What i'm looking for is an if statement that will check to see if the value exists in the registry. If it does not exist, it will popup a message box then exit. If it DOES exist, it will set %AppFolder% as the registry value.

Here's what i want:

SessionVar.Set("%AppFolder%", Registry.GetValue(HKEY_LOCAL_MACHINE, "Software\\My Product", "Installed Path", true));

I've tried some different IF statements but so far unsuccessful.

Any help would be much appreciated!

Thanks alot!

pww
08-24-2009, 03:13 PM
maybe something like this


myPath = Registry.GetValue(....);
if Folder.DoesExist(myPath) then
SessionVar.Set("%AppFolder%",myPath);
else
Dialog.Message("Error", "Installation not found");
Application.Exit();
end;

FrostByte
08-24-2009, 04:08 PM
Excellent pww thanks for that, however is there a way to expand that code to check if the registry value exists? NOTE: not the registry key, the value itself (Installed Path)

Thanks for your help :)

pww
08-26-2009, 04:43 PM
if myPath is not an empty string, value exists.
If it is an empty string, value either does not exist or contains no data.

if myPath=="" then
Dialog.Message("oops", "Value does not exist");
end

FrostByte
08-27-2009, 01:23 PM
thanks alot mate, much appreciated :)