private WindowsBrowser getBrowserFromRegistryEntry(
     Regor regor, int key, String subKey, String exeKey, Map exesToBrowserObjs)
     throws RegistryErrorException {
   WindowsBrowser winBrowser = null;
   int key2 = regor.openKey(key, subKey);
   List values = regor.listValueNames(key2);
   // boolean fndPath = false;
   for (int x = 0; values != null && x < values.size() && winBrowser == null; x++) {
     byte[] buf = regor.readValue(key2, (String) values.get(x));
     String path = buf != null ? Regor.parseValue(buf) : "";
     String lpath = path.toLowerCase();
     if (lpath.endsWith(exeKey)) {
       winBrowser = (WindowsBrowser) exesToBrowserObjs.get(exeKey);
       // get path to exe and set it in winBrowser object
       StringTokenizer tokenizer = new StringTokenizer(path, "\\", false);
       StringBuffer pathBuf = new StringBuffer();
       int tokCnt = tokenizer.countTokens();
       // we want to ignore the last token
       for (int idx = 1; idx < tokCnt; idx++) {
         pathBuf.append(tokenizer.nextToken());
         pathBuf.append('\\');
       }
       winBrowser.setPathToExe(pathBuf.toString());
     }
   }
   return winBrowser;
 }
 /**
  * Accesses the Windows registry to look for browser exes. The browsers search for are in the
  * browsersToCheck list. The returned map will use display names and exe names as keys to the
  * {@link WindowsBrowser WindowsBrowser} objects.
  *
  * @param browsersToCheck List
  * @return Map
  */
 private Map getAvailableBrowsers(List tempBrowsersToCheck) {
   logger.debug("finding available browsers using registry");
   logger.debug("browsers to check: " + tempBrowsersToCheck);
   Map browsersAvailable = new TreeMap(String.CASE_INSENSITIVE_ORDER);
   try {
     // create map of exe names to win browser objects
     Map exesToBrowserObjs = getExeNamesToBrowsers(tempBrowsersToCheck);
     // access and look in registry
     Regor regor = new Regor();
     String subKeyName = "Software\\Microsoft\\Windows\\CurrentVersion\\App Paths";
     int key = regor.openKey(Regor.HKEY_LOCAL_MACHINE, subKeyName);
     if (key > -1) {
       List keys = regor.listKeys(key);
       Collections.sort(keys, String.CASE_INSENSITIVE_ORDER);
       Iterator keysIter = exesToBrowserObjs.keySet().iterator();
       while (keysIter.hasNext()) {
         String exeKey = (String) keysIter.next();
         int index = Collections.binarySearch(keys, exeKey, String.CASE_INSENSITIVE_ORDER);
         if (index >= 0) {
           WindowsBrowser winBrowser =
               getBrowserFromRegistryEntry(
                   regor, key, (String) keys.get(index), exeKey, exesToBrowserObjs);
           if (winBrowser != null) {
             if (logger.isDebugEnabled()) {
               logger.debug(
                   "Adding browser " + winBrowser.getBrowserDisplayName() + " to available list.");
               logger.debug(winBrowser.getPathToExe());
             }
             // adding display and exe for backward compatibility and
             // ease of use if someone passes in the name of an exe
             browsersAvailable.put(winBrowser.getBrowserDisplayName(), winBrowser);
             browsersAvailable.put(winBrowser.getBrowserApplicationName(), winBrowser);
             tempBrowsersToCheck.remove(winBrowser);
           }
         }
       }
     }
   } catch (RegistryErrorException ex) {
     logger.error("problem accessing registry", ex);
   }
   return browsersAvailable;
 }