During setup.exe installation if a particular key exists in registry i want to abort the installation.To achieve this,i am calling install-script function using custom action in install shield project. Install Script code is :
function MyFunction(hMSI)
// To Do: Declare local variables.
STRING szKey;
NUMBER nRootKey;
begin
// Set the root key to HKEY_LOCAL_MACHINE.
nRootKey = HKEY_LOCAL_MACHINE;
if (RegDBSetDefaultRoot (nRootKey) < 0) then
MessageBox ("First call to RegDBSetDefaultRoot failed.", SEVERE);
else
MessageBox ("Root key successfully set to HKEY_LOCAL_MACHINE.",
INFORMATION);
endif;
szKey = "SOFTWARE\\Test";
if (RegDBKeyExist (szKey)< 0) then
MessageBox ("Test is not present", SEVERE);
abort;
endif;
if (RegDBKeyExist (szKey)= 1) then
MessageBox ("Test is present", SEVERE);
abort;
endif;
// To Do: Write script that will be executed when MyFunction is called.
end;
Every time i am getting message "Test is not present" even though key "HKEY_LOCAL_MACHINE\SOFTWARE\Test" is present in registry.
I think i did some what wrong in script or missing something. Please help on this.
https://community.flexerasoftware.com/showthread.php?139026-Check-if-a-registry-key-exists