Checking if a Product Is Installed

InstallShield 2020 Express Edition

The following code will check if a product with a ProductCode of {8FC71000-88A0-4B41-82B8-8905D4AA904C} is installed on the machine. This code can be used as a New Style DLL Custom Action.

UINT __stdcall CheckProduct(MSIHANDLE hInstall)

{

int RetVal = 0;

RetVal = MsiQueryProductState("{8FC71000-88A0-4B41-82B8-8905D4AA904C}");

if (RetVal==5))

{

MessageBox(GetForegroundWindow(),TEXT("Installed"),TEXT("My Product"), MB_OK);

return 1;

}

else

{

MessageBox(GetForegroundWindow(),TEXT("Not Installed"),TEXT("My Product"), MB_OK);

return 0;

}

}

The following table lists the return values of MsiQueryProductState:

Return Values of MsiQueryProductState

Return Value

Description

–1

The product is neither advertised nor installed.

1

The product is advertised but not installed.

2

The product is installed for a different user.

5

The product is installed for the current user.