Revenera logo

Scripting languages are dandy, but what about integrating your InstallShield builds with something like an InstallAnywhere build?  Java is the language of choice in this case.

There is some bad news, however.  Java does not natively support working with COM, and so this requires an interop layer in order to get it to work.

There’s a few third-party projects available for the Java/COM Interop layer:

In the below example, we’ll be using the JACOB interop library, which requires adding a reference to the jacob.jar, and installing the interop *.dll to the Windows System folder.

Some things to note about this example is that this Interop library requires direct calls to the IDispatch interface, rather than obfuscating it for ease of use and readability. As such, this gives a much better view into how COM works on the back end, albeit being much less readable.

Some notable aspects here are that what shows up as almost a function call for selecting a particular feature is indeed a function call (Dispatch.Call()), and as well what was simple assignment before is now Dispatch.put().

Due to the put() function’s need for a Variant, we’ve needed to populate a Variant explicitly with our Enum type (as the Constructor for Variant(int) seems to have issues in JACOB…).

Another bit of confusion specific to using JACOB is that the standard Dispatch method for grabbing a named item from a collection (get_Item()) doesn’t seem to exist.  The same functionality you get from using Dispatch.Call with the named item specified.

ISWiFeatures

This example illustrates iterating through root level features and components.

public static void main(String[] args) {

String myProject = “C:InstallShield 2011 ProjectsMY 64 bit Project.ism”;

String strProject = “”;

ActiveXComponent ISWiCom;
Variant ISWiComponents;
Variant Name;
Dispatch MyFeature,MyComponent;

ISWiCom = new ActiveXComponent(“ISWiAuto17.ISWiProject”);

Dispatch ISWiProject = (Dispatch)ISWiCom.getObject();

Dispatch.call(ISWiProject, “OpenProject”, myProject);

Variant ISWiFeatures = Dispatch.get(ISWiProject, “ISWiFeatures”);

for(Enumeration<Variant> ISWiFeature = new EnumVariant(ISWiFeatures.getDispatch()); ISWiFeature.hasMoreElements();)
{
MyFeature = new Dispatch(ISWiFeature.nextElement().getDispatch());
Name = Dispatch.get(MyFeature, “Name”);

strProject += “Feature: ” + Name + “n”;
strProject += “Components: “;

ISWiComponents = Dispatch.get(MyFeature, “ISWiComponents”);

for(Enumeration<Variant> ISWiComponent = new EnumVariant(ISWiComponents.getDispatch()); ISWiComponent.hasMoreElements();)
{
MyComponent = new Dispatch(ISWiComponent.nextElement().getDispatch());

Name = Dispatch.get(MyComponent,”Name”);
strProject += Name + ” “;
}
}
System.out.println(strProject);
Dispatch.call(ISWiProject, “CloseProject”);
}

ISWiComponents

This example illustrates getting a specific feature from the ISWiFeatures collection, and using it to set component properties, and then saving the project.

public enum RemoteInstallation{
rfsLocal,rfsSource,rfsOptional
}

public static void main(String[] args) {

String myProject = “C:InstallShield 2011 ProjectsMY 64 bit Project.ism”;

ActiveXComponent ISWiCom;
Variant ISWiComponents;
Dispatch MyComponent;
Variant RIType = new Variant();

RIType.putInt(RemoteInstallation.rfsSource.ordinal());

ISWiCom = new ActiveXComponent(“ISWiAuto17.ISWiProject”);

Dispatch ISWiProject = (Dispatch)ISWiCom.getObject();

InstallShield icon

InstallShield

Create native MSIX packages, build clean installs, and build installations in the cloud with InstallShield from Revenera.

Dispatch.call(ISWiProject, “OpenProject”, myProject);

Dispatch ISWiFeatures = Dispatch.get(ISWiProject, “ISWiFeatures”).toDispatch();
Dispatch MyFeature = Dispatch.call(ISWiFeatures, “Item”,”MyApplication”).toDispatch();

ISWiComponents = Dispatch.get(MyFeature, “ISWiComponents”);

for(Enumeration<Variant> ISWiComponent = new EnumVariant(ISWiComponents.getDispatch()); ISWiComponent.hasMoreElements();)
{
MyComponent = new Dispatch(ISWiComponent.nextElement().getDispatch());
Dispatch.put(MyComponent, “RemoteInstallation”, RIType);
}
Dispatch.call(ISWiProject, “SaveProject”);
Dispatch.call(ISWiProject, “CloseProject”);
}