cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
BethanyK
Level 3

Getting a false positive on a RegDBKeyExist check.

I created a copy of a functioning installer I created to create a similar installer with slightly different requirements. In my OnAppSearch funtion I had some logic that used RegDBKeyExist to determine if a required piece of software is installed before proceeding. I have verified that the registry key I'm checking against does not exist on my test machine but the function is returning a postive anyway. Any ideas?
Labels (1)
0 Kudos
(6) Replies
RobertDickau
Flexera Alumni

Perhaps post the code that fails, including any preliminaries such as RegDBSetDefaultRoot? Any difference between systems, such as 32-bit vs. 64-bit?
0 Kudos
BethanyK
Level 3

I have modified some of this for non disclosure. Note I put an additional message box in to assure that this was the path I was falling into:

//---------------------------------------------------------------------------
// OnAppSearch
//
// The OnAppSearch event is called after OnBegin and can be used to search
// for previous versions of the current application. This event is called
// only when the setup is running in first install mode.
//---------------------------------------------------------------------------
function OnAppSearch()
NUMBER nResult;
STRING svInstallPath;
NUMBER nSize;
NUMBER nType;

begin
RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
if (RegDBKeyExist(" MessageBox("False Positive!", SEVERE);
abort;

FeatureSetTarget(MEDIA,"",svInstallPath + "");
else
MessageBox("Error Message", SEVERE);
abort;
endif;
end;
0 Kudos
RobertDickau
Flexera Alumni

Perhaps change the return value test to
if (RegDBKeyExist("...") != 1) then // etc.
RegDBKeyExist is odd in that it returns 1 for success, not 0.
0 Kudos
BethanyK
Level 3

It is still falling into that loop with that code change. The only difference between this code and what I had working in the previous copy of this installer is that had a further check on a registry value. Perhaps the RegDBKeyExist call never actually worked to begin with.
0 Kudos
RobertDickau
Flexera Alumni

As a test, does this work as expected?
function OnAppSearch( )
begin

RegDBSetDefaultRoot(HKEY_CLASSES_ROOT);

if (RegDBKeyExist("no\\such\\key") != 1) then
MessageBox("No such key exists, which is no surprise.", INFORMATION);
else
MessageBox("Found it, though I shouldn't have.", INFORMATION);
endif;

end;
0 Kudos
BethanyK
Level 3

Oh dear...when you posted that code sample I realized something. Your original suggestion was to use != 1 but I wanted to fall into that if it was equal to 1. Changed it to == 1 and now it works fine. Thanks for your help!
0 Kudos