PreviousNext
Help Library

Using the InstallShield MSDE 2000 Object for NT Platforms in an InstallScript MSI Project

InstallShield 12

To use the InstallShield MSDE 2000 Object for NT Platforms in an InstallScript MSI project, you must add code to your installation script. This is because a limitation of MSDE 2000 is that it cannot be installed as a nested .msi file; so an installation cannot run the MSDE 2000 installation from the InstallExecute sequence but must run it from the Install UI sequence, which in InstallScript MSI projects is executed by the script. You must add two new functions, one to install MSDE 2000 and the other to uninstall it, and then call them in your script, as described in the following steps.

Task

TASK

To use the InstallShield MSDE 2000 Object for NT Platforms in an InstallScript MSI project:

  1. Place the following three function declarations in the function prototypes section of your script (below the line #include "ifx.h"):
  2. prototype int Msi.MsiGetPropertyA(int, byval string, byref string, 
    byref int);
    
    
    prototype InstallMSDE();
    
    
    prototype UninstallMSDE();
    
    
  3. Place function definitions like the following examples at the end of your script. Be sure to replace YourMSDEFeatureName in the call to FeatureIsItemSelected with the name of the feature with which the MDSE object is associated. You can customize the following code to meet your particular needs.
  4. function InstallMSDE()
    
    
        string szPropVal, svResult;
    
    
        number nBuffer, nResult, nvResult;   
    
    
        BOOL bFeatVal;
    
    
    begin
    
    
        nBuffer = MAX_PATH;
    
    
        bFeatVal = FeatureIsItemSelected ( MEDIA , 
    "YourMSDEFeatureName" );
    
    
        MsiDoAction(ISMSI_HANDLE,
    
    
            "CheckInstance.DEAEC3E7_8F5C_4115_ABD3_E5742E47D469");
    
    
        nResult = 
    Msi.MsiGetPropertyA(ISMSI_HANDLE,"INSTANCEFOUND",szPropVal,nBuffer
    );
    
    
        GetSystemInfo (OS, nvResult, svResult);
    
    
        if ((szPropVal="")&&(bFeatVal=TRUE)) then
    
    
            if (nvResult=IS_WINDOWS9X) then
    
    
                MessageBox("Can't install MSDE on Windows 9X machines. 
    " +
    
    
                    "Please contact your setup provider for more 
    information. " +
    
    
                    "Setup will now exit.", WARNING);
    
    
                abort;
    
    
            else
    
    
                MessageBox("Preparing the MSDE 2000 setup. " +
    
    
                    "This may take a few minutes...", INFORMATION);  
    
    
                nResult = MsiDoAction(ISMSI_HANDLE,
    
    
                    "InstallMSDE.DEAEC3E7_8F5C_4115_ABD3_E5742E47D469");
    
    
                if (nResult!=0) then
    
    
                    MessageBox("MSDE 2000 Installation failed. " +
    
    
                        "Setup will now stop.", WARNING);
    
    
                    abort;
    
    
                else
    
    
                    nResult = Msi.MsiGetPropertyA(ISMSI_HANDLE,
    
    
                        "REBOOTISMSDE2000",szPropVal,nBuffer);
    
    
                    if (szPropVal="") then
    
    
                        MsiDoAction(ISMSI_HANDLE,
    
    
                            
    "SetReboot.DEAEC3E7_8F5C_4115_ABD3_E5742E47D469");
    
    
                    endif;
    
    
                endif;
    
    
            endif;
    
    
        endif;       
    
    
    end;
    
    
     
    
    
    function UninstallMSDE()
    
    
        string szUninstKey, svUninstVal, svRemMSDE, szProdCode;
    
    
        number BufSize, nvType, nResult;
    
    
    begin
    
    
        nvType = REGDB_STRING; 
    
    
        BufSize = MAX_PATH;
    
    
        nResult = 
    Msi.MsiGetPropertyA(ISMSI_HANDLE,"ProductCode",szProdCode,BufSize)
    ;
    
    
        szUninstKey = 
    "SOFTWARE\\InstallShield\\ObjectRuntime\\ISMSDE2000\\" + 
    szProdCode;
    
    
        RegDBSetDefaultRoot ( HKEY_LOCAL_MACHINE );  
    
    
        RegDBGetKeyValueEx ( szUninstKey, "UninstallKey" , nvType, 
    svUninstVal , BufSize);             
    
    
        nResult = 
    Msi.MsiGetPropertyA(ISMSI_HANDLE,"REMOVEMSDE",svRemMSDE,BufSize);
    
    
        if ((svRemMSDE!="")&&(svUninstVal!="")) then
    
    
            MsiDoAction(ISMSI_HANDLE,
    
    
                "UninstallMSDE.DEAEC3E7_8F5C_4115_ABD3_E5742E47D469");
    
    
        endif;           
    
    
    end;
    
    
  5. Call InstallMSDE in the OnFirstUIBefore event handler function just before or after the line Enable(STATUSEX);.
  6. Call UninstallMSDE in the OnMaintUIBefore event handler function just before the Dlg_Start block's endif statement, so that UninstallMSDE is called only if the end user selects and confirms uninstallation.



Macrovision Corporation
copyright
contact