Accessing an Object’s Properties

InstallShield 2015

There are two different points in time when your properties can be changed, after you have compiled your object. The first is when your object is added to an installation project. If you provide a wizard interface for your object, its read/write properties can be changed during an installation’s design time. The second way to change a property is during run time through script. In order to allow the users of your object to access its properties during run time, you need to document those properties in the object’s help topic. With that documentation, your users should be able to change those properties as needed.

Accessing a Property from the InstallShield Interface

When you access an object’s properties from within your installation project, you are actually running portions of that object’s script right in the InstallShield interface. For example, when you associate an object with your installation project, the object’s properties are read with the get_PropertyName function that is built into every object containing properties. Alternatively, when you change an object’s properties through the object’s wizard, the put_PropertyName function is called, where PropertyName is the name of the property that you are changing.

Accessing a Property Through Script

To access an object’s properties, you must first get a reference to that object. Then, you need to specify which of the object’s properties you would like to access. The following code illustrates how to return an object’s status property:

function OnBegin()

   /* Declare an object variable to hold a reference to the object. */

   OBJECT oObject;

begin

   /* Get a reference to a custom object named "My Custom Object".*/

     set oObject = GetObject("My Custom Object");

 

   /* Check the Status.Number property. */

   if oObject.Status.Number != OBJ_STATUS_SUCCESS then

      /* Respond to the error as appropriate for your setup.

      For example, you can display the Status.Description

      text and abort the setup. */

      MessageBox ( oObject.Status.Description, SEVERE );

      abort;

   endif;

end;

When you change a property at run time, that information is not stored for future uses of the installation. For example, if the installation is later run in maintenance mode, that property will not retain the value it was given during the initial installation.

If a Boolean property’s value is set to TRUE, either by the object script or the script of the installation that includes the object, subsequent checks of the property’s value will show the value to be –1 rather than 1.

Tip: If you simply want to retrieve the current status of an object (that is, the current value of Status.Number) in the InstallScript Object, you can use the GetStatus function. For more information, see GetStatus.