PDA

View Full Version : Getting your current version



Jennell Little
04-14-2006, 10:39 AM
Is there a way using the InstallShield APIs to get the current version that is being installed? I tried using $P(<myrootbean>.key.version.major).$P(<myrootbean>.key.version.minor) as Robert Dickau suggested in aother post but that doesn't seem to work for me.

RobertDickau
04-14-2006, 12:37 PM
As a quick test, this wizard action seems to do it:
import com.installshield.wizard.*;
import com.installshield.wizard.service.*;
import com.installshield.product.*;
import com.installshield.product.service.product.*;

public class GetVersionTest extends WizardAction
{
private static final String SRC = ProductService.DEFAULT_PRODUCT_SOURCE;

public void execute(WizardBeanEvent event)
{
try
{
ProductService ps = (ProductService)getService(ProductService.NAME);
String rootbeanid = ps.getProductTreeRoot(SRC);

SoftwareObjectKey rootsok =
(SoftwareObjectKey)ps.getProductBeanProperty(
SRC, rootbeanid, "key");

SoftwareVersion sv = rootsok.getVersion( );

javax.swing.JOptionPane.showMessageDialog(null,
sv.getMajor( ) + "." +
sv.getMinor( ) + "." +
sv.getMaintenance( ));

} catch(ServiceException drat) { drat.printStackTrace( ); }
}
}

Jennell Little
04-18-2006, 07:52 PM
That was exactly what I needed. It works great. Thanks!