PDA

View Full Version : how do I tell if a feature is already installed?



kenmckinney
06-05-2002, 08:11 PM
Hey,

My installer needs to be able to tell if a particular feature (which actually wraps a merge module) is already installed on the target system. According to the IS 7.03 help, I use

FeatureIsItemSelected(MEDIA,"featurename")

for this. FeatureIsItemSelected appears to call MsiGetFeatureState.

However, when I run, FeatureIsItemSelected returns TRUE even when the feature has not previously been installed to the target machine.

Am I doing something wrong?

Ken McKinney

mgrove
06-06-2002, 10:30 AM
FeatureIsItemSeleted() tells you if the feature is installed OR has been requested to be Installed. I think what you want to to is call MSIGetFeatureState(), and check to see if it is greater than INSTALLSTATE_ABSENT. Check out the MSI Documentation on msdn.microsoft.com for more information...

kenmckinney
06-06-2002, 03:48 PM
wow, thanks for the help!

I am using the following code, which seems to work now:

function LCEngineInstalled()
NUMBER nInstalled,nAction;
begin
MsiGetFeatureState(ISMSI_HANDLE,"LearningConductorEngine",nInstalled,nAction);
if nInstalled > INSTALLSTATE_ABSENT then
AddToLog("LC Engine is installed");
return TRUE;
else
AddToLog("LC Engine is not installed");
return FALSE;
endif;
end;

I notice that MsiGetFeatureState can return a lot of constants...is it really the case that nInstalled > INSTALLSTATE_ABSENT works? IE, are these constants ordered in the appropriate numeric sequence? It seems to be OK on my machine, but I don't want to get burned later ;-)

Ken McKinney

mgrove
06-06-2002, 04:34 PM
Yep. Here is the list of constants and thier respective values (Exctracted from MSI.h, included with the MSI SDK)

INSTALLSTATE_NOTUSED = -7, // component disabled
INSTALLSTATE_BADCONFIG = -6, // configuration data corrupt
INSTALLSTATE_INCOMPLETE = -5, // installation suspended or in progress
INSTALLSTATE_SOURCEABSENT = -4, // run from source, source is unavailable
INSTALLSTATE_MOREDATA = -3, // return buffer overflow
INSTALLSTATE_INVALIDARG = -2, // invalid function argument
INSTALLSTATE_UNKNOWN = -1, // unrecognized product or feature
INSTALLSTATE_BROKEN = 0, // broken
INSTALLSTATE_ADVERTISED = 1, // advertised feature
INSTALLSTATE_REMOVED = 1, // component being removed (action state, not settable)
INSTALLSTATE_ABSENT = 2, // uninstalled (or action state absent but clients remain)
INSTALLSTATE_LOCAL = 3, // installed on local drive
INSTALLSTATE_SOURCE = 4, // run from source, CD or net
INSTALLSTATE_DEFAULT = 5, // use default, local or source

I actually use this to determine if a feature exists within a package. If not, it returna a negitive value... ;-)

kenmckinney
06-06-2002, 06:47 PM
hey, this is great. Thank you very much.

Ken McKinney