public void registerUninstallKey() throws NativeLibException {
    String uninstallName = getUninstallName();
    if (uninstallName == null) {
      return;
    }
    String keyName = UNINSTALL_ROOT + uninstallName;
    String cmd =
        "\""
            + installdata.getVariable("JAVA_HOME")
            + "\\bin\\javaw.exe\" -jar \""
            + installdata.getVariable("INSTALL_PATH")
            + "\\uninstaller\\uninstaller.jar\"";
    String appVersion = installdata.getVariable("APP_VER");
    String appUrl = installdata.getVariable("APP_URL");

    int oldVal = getRoot();
    try {
      setRoot(HKEY_LOCAL_MACHINE);
      setValue(keyName, "DisplayName", uninstallName);
    } catch (
        NativeLibException
            exception) { // Users without administrative rights should be able to install the app
                         // for themselves
      Debug.trace(
          "Failed to register uninstaller in HKEY_LOCAL_MACHINE hive, trying HKEY_CURRENT_USER: "******"DisplayName", uninstallName);
    }
    setValue(keyName, "UninstallString", cmd);
    setValue(keyName, "DisplayVersion", appVersion);
    if (appUrl != null && appUrl.length() > 0) {
      setValue(keyName, "HelpLink", appUrl);
    }
    // Try to write the uninstaller icon out.
    try {
      InputStream input = ResourceManager.getInstance().getInputStream(UNINSTALLER_ICON);
      String iconPath =
          installdata.getVariable("INSTALL_PATH")
              + File.separator
              + "Uninstaller"
              + File.separator
              + "UninstallerIcon.ico";
      FileOutputStream out = new FileOutputStream(iconPath);
      byte[] buffer = new byte[5120];
      long bytesCopied = 0;
      int bytesInBuffer;
      while ((bytesInBuffer = input.read(buffer)) != -1) {
        out.write(buffer, 0, bytesInBuffer);
        bytesCopied += bytesInBuffer;
      }
      input.close();
      out.close();
      setValue(keyName, "DisplayIcon", iconPath);
    } catch (Exception exception) { // May be no icon resource defined; ignore it
      Debug.trace(exception);
    }
    setRoot(oldVal);
  }
 /**
  * Gets the stream to a resource.
  *
  * @param res The resource id.
  * @return The resource value, null if not found
  */
 public InputStream getResource(String res) {
   try {
     // System.out.println ("retrieving resource " + res);
     return ResourceManager.getInstance().getInputStream(res);
   } catch (Exception e) { // Cannot catch ResourceNotFoundException because it is not public.
     return null;
   }
 }
Ejemplo n.º 3
0
 /** Loads the info text. */
 private void loadInfo() {
   try {
     String resNamePrifix = "InfoPanel.info";
     info = ResourceManager.getInstance().getTextResource(resNamePrifix);
   } catch (Exception err) {
     info = "Error : could not load the info text !";
   }
 }
 /** Loads the info text. */
 private void loadInfo() {
   try {
     // We read it
     info = ResourceManager.getInstance().getTextResource("XInfoPanel.info");
   } catch (Exception err) {
     info = "Error : could not load the info text !";
   }
 }
 /**
  * Loads the info.
  *
  * @return The info URL.
  */
 private URL loadInfo() {
   String resNamePrifix = "HTMLInfoPanel.info";
   try {
     return ResourceManager.getInstance().getURL(resNamePrifix);
   } catch (Exception ex) {
     ex.printStackTrace();
   }
   return null;
 }