cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Jeff_Morse
Level 6

Win32RegistryService in custom code

Hi,

I am writing some customcode to access the Windows registry and it is not compiling. I get a the following error in my ant output:

[CODE] [javac] ...\customcode\com\progress\devstudio\install\action\FindPathInWindowsRegistry.java:84: cannot access com.installshield.wizard.service.Service
[javac] class file for com.installshield.wizard.service.Service not found
[javac] String[] instanceKeys = wrs.getSubkeyNames(hive, winregKeyProduct);
[javac] ^[/CODE]

I searched these forums for answers and found this thread: http://community.flexerasoftware.com/showthread.php?t=183357. Following Robert Dickau's final post, I have services.jar and windowsppk.jar in my classpath, but I cannot figure out how to "Add service support for custom code" in my IA2011 project. Does anyone know how to do that?

Below is my java. If you could help me get past this compiling issue that would be great.

-Jeff

[CODE]
import com.zerog.ia.api.pub.*;
import com.installshield.wizard.service.*;
import com.installshield.wizard.platform.win32.*;

public class FindPathInWindowsRegistry extends CustomCodeAction
{
public void install( InstallerProxy ip ) throws InstallException
{
// Get Input vars
String pathToMatch = ip.substitute("$PATH_TO_MATCH$");
String winregKeyProduct = ip.substitute("$WINREG_KEY_PRODUCT$");

// Init some vars
int hive = 0;
String pathMatch = "false";
String winregKeyProductInstance = null;

Win32RegistryService wrs = (Win32RegistryService) ip.getService(Win32RegistryService.class);

try
{
hive = wrs.HKEY_LOCAL_MACHINE;

String[] instanceKeys = wrs.getSubkeyNames(hive, winregKeyProduct);

for ( int i=1; i {
if ( wrs.getStringValue(hive, instanceKeys, "Path", true).matches(pathToMatch) )
{
winregKeyProductInstance = instanceKeys;
pathMatch = "true";
break;
}
}
}
catch(ServiceException se) {
//System.out.println(se.getMessage());
se.printStackTrace( );
}

// Set Output vars
ip.setVariable("$WINREG_KEY_PRODUCT_INSTANCE$", winregKeyProductInstance);
ip.setVariable("$PATH_MATCH$", pathMatch);
}
// ...
}
[/CODE]
Labels (1)
0 Kudos
(4) Replies
pv7721
Level 20

Open your project in Advanced Designer, then go to Project/Java, there you'll find the "Add service support for custom code" checkbox.
0 Kudos
Jeff_Morse
Level 6

Thanks Vlad. I swear I didn't see that before. sigh. It must've been on the "Installer Settings" tab and I, foolishly, never clicked the "General Settings" tab.

-Jeff
0 Kudos
Jeff_Morse
Level 6

Does anyone know why my code isn't compiling? Please help!
0 Kudos
Jeff_Morse
Level 6

Problem solved.

I took a break from this issue for a bit, tried it again, this time with my classpath properly set, and, magically, it compiled. Funny how that works...

Oh, I also needed uninstall, getInstallStatusMessage and getUninstallStatusMessage methods. Without them I got this error: ... is not abstract and does not override abstract method getUninstallStatusMessage() in com.zerog.ia.api.pub.CustomCodeAction.

-Jeff
0 Kudos