cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
alon2580
Level 5

Creating a REG_MULTI_SZ key in registry during installation

Hi,
During installations I need to create a couple of keys in the registry.
Installanywhere can handle STRING,DWORD and BINARY values, but I need a REG_MULTI_SZ value.
Does any one have any idea how to do it?
10x
Alon
Labels (1)
0 Kudos

(7) Replies
RobertDickau
Flexera Alumni

If the multi-string data are constant, perhaps you could export a .reg file from regedit on your system, and then from the installer run the command regedit.exe /s filename.reg. There might need to be another action to remove the data during uninstall.

If the data are dynamic, perhaps you could use the Win32RegistryService methods in a custom code action.
0 Kudos
alon2580
Level 5

The data is dynamic so the first option in not good.
Java doesn't support adding this type of data(REG_MULTI_SZ)to the registry for that you need to use the jni and I'm trying to avoid it.
Any other solution?
0 Kudos
RobertDickau
Flexera Alumni

Actually, the Win32RegistryService interface (please see the javadoc API documentation) should take care of the JNI part, so you can write the code using just Java...
0 Kudos
alon2580
Level 5

I'm really just an amateur when it's gets to Java. and what I said its what I understood from google 😮 . can you please explain what you mean?
don't I need to write a code in lets say c++ and than call it from Java- isn't that what jni means?
0 Kudos
RobertDickau
Flexera Alumni

That is correct about JNI in general, but much of the InstallAnywhere API is implemented such that you need to deal with only the Java interface in your custom code actions; the JNI for the IA API is invisibly called in the background...
0 Kudos
alon2580
Level 5

I'm still kind of in the dark here:(
Any chance for an example or a guide or something
Thanks
0 Kudos
RobertDickau
Flexera Alumni

Code for an action using the service might look like this:
[code]import com.zerog.ia.api.pub.*;
import com.installshield.wizard.service.*;
import com.installshield.wizard.platform.win32.*;

public class TestWin32Registry extends CustomCodeAction
{
public void install(InstallerProxy ip) throws InstallException
{
// get an instance of the service
Win32RegistryService winregsvc =
(Win32RegistryService)ip.getService(Win32RegistryService.class);

try {
// create the key first...
winregsvc.createKey(
Win32RegistryService.HKEY_CLASSES_ROOT,
"", "...MyKeyName");

// ...then create values inside it
winregsvc.setMultiStringValue(
Win32RegistryService.HKEY_CLASSES_ROOT,
"...MyKeyName", "MyValueName",
new String[] { "aaa", "bbb", "ccc", "ddd", "eee" });

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

public void uninstall(UninstallerProxy up) throws InstallException
{
// TO DO: handle uninstallation...
}

public String getInstallStatusMessage( ) { return "Writing registry values..."; }
public String getUninstallStatusMessage( ) { return "Nothing..."; }
}[/code]
You'll need IAClasses.zip, resource\services\services.jar, and resource\services\ppk\windowsppk.jar on the compiler build path.

In the project, you'll also need to select Project > Java > Add service support for custom code.

After that, you should be able to add the packaged custom class to your project, and the JNI code behind Win32RegistryService should create the data for you...
0 Kudos