src/windows/bin/java_md.c
static char *
ProcessDir(manifest_info* info, HKEY top_key) {
    DWORD   index = 0;
    HKEY    ver_key;
    char    name[MAXNAMELEN];
    int     len;
    char    *best = NULL;

    /*
     * Enumerate "<top_key>/SOFTWARE/JavaSoft/Java Runtime Environment"
     * searching for the best available version.
     */
    while (RegEnumKey(top_key, index, name, MAXNAMELEN) == ERROR_SUCCESS) {
        index++;
        if (JLI_AcceptableRelease(name, info->jre_version))
            if ((best == NULL) || (JLI_ExactVersionId(name, best) > 0)) {
                if (best != NULL)
                    JLI_MemFree(best);
                best = JLI_StringDup(name);
            }
    }

    /*
     * Extract "JavaHome" from the "best" registry directory and return
     * that path.  If no appropriate version was located, or there is an
     * error in extracting the "JavaHome" string, return null.
     */
    if (best == NULL)
        return (NULL);
    else {
        if (RegOpenKeyEx(top_key, best, 0, KEY_READ, &ver_key)
          != ERROR_SUCCESS) {
            JLI_MemFree(best);
            if (ver_key != NULL)
                RegCloseKey(ver_key);
            return (NULL);
        }
        JLI_MemFree(best);
        len = MAXNAMELEN;
        if (RegQueryValueEx(ver_key, "JavaHome", NULL, NULL, (LPBYTE)name, &len)
          != ERROR_SUCCESS) {
            if (ver_key != NULL)
                RegCloseKey(ver_key);
            return (NULL);
        }
        if (ver_key != NULL)
            RegCloseKey(ver_key);
        return (JLI_StringDup(name));
    }
}
/*
 * Determine if there is an acceptable JRE in the registry directory top_key.
 * Upon locating the "best" one, return a fully qualified path to it.
 * "Best" is defined as the most advanced JRE meeting the constraints
 * contained in the manifest_info. If no JRE in this directory meets the
 * constraints, return NULL.
 *
 * It doesn't matter if we get an error reading the registry, or we just
 * don't find anything interesting in the directory.  We just return NULL
 * in either case.
 */
Determine if there is an acceptable JRE in the registry directory top_key.
Upon locating the "best" one, return a fully qualified path to it.
"Best" is defined as the most advanced JRE meeting the constraints
contained in the manifest_info. If no JRE in this directory meets the
constraints, return NULL.

It doesn't matter if we get an error reading the registry, or we just
don't find anything interesting in the directory.  We just return NULL
in either case.
Determine if there is an acceptable JRE in the registry directory top_key . Upon locating the " best " one return a fully qualified path to it . " Best " is defined as the most advanced JRE meeting the constraints contained in the manifest_info . If no JRE in this directory meets the constraints return NULL . It doesn ' t matter if we get an error reading the registry or we just don ' t find anything interesting in the directory . We just return NULL in either case .
static char *
ProcessDir(manifest_info* info, HKEY top_key) {
    DWORD   index = 0;
    HKEY    ver_key;
    char    name[MAXNAMELEN];
    int     len;
    char    *best = NULL;
    while (RegEnumKey(top_key, index, name, MAXNAMELEN) == ERROR_SUCCESS) {
        index++;
        if (JLI_AcceptableRelease(name, info->jre_version))
            if ((best == NULL) || (JLI_ExactVersionId(name, best) > 0)) {
                if (best != NULL)
                    JLI_MemFree(best);
                best = JLI_StringDup(name);
            }
    }
    if (best == NULL)
        return (NULL);
    else {
        if (RegOpenKeyEx(top_key, best, 0, KEY_READ, &ver_key)
          != ERROR_SUCCESS) {
            JLI_MemFree(best);
            if (ver_key != NULL)
                RegCloseKey(ver_key);
            return (NULL);
        }
        JLI_MemFree(best);
        len = MAXNAMELEN;
        if (RegQueryValueEx(ver_key, "JavaHome", NULL, NULL, (LPBYTE)name, &len)
          != ERROR_SUCCESS) {
            if (ver_key != NULL)
                RegCloseKey(ver_key);
            return (NULL);
        }
        if (ver_key != NULL)
            RegCloseKey(ver_key);
        return (JLI_StringDup(name));
    }
}
static char * ProcessDir ( manifest_info * info , HKEY top_key ) { DWORD index = 0 ; HKEY ver_key ; char name [ MAXNAMELEN ] ; int len ; char * best = NULL ; while ( RegEnumKey ( top_key , index , name , MAXNAMELEN ) == ERROR_SUCCESS ) { index ++ ; if ( JLI_AcceptableRelease ( name , info -> jre_version ) ) if ( ( best == NULL ) || ( JLI_ExactVersionId ( name , best ) > 0 ) ) { if ( best != NULL ) JLI_MemFree ( best ) ; best = JLI_StringDup ( name ) ; } } if ( best == NULL ) return ( NULL ) ; else { if ( RegOpenKeyEx ( top_key , best , 0 , KEY_READ , & ver_key ) != ERROR_SUCCESS ) { JLI_MemFree ( best ) ; if ( ver_key != NULL ) RegCloseKey ( ver_key ) ; return ( NULL ) ; } JLI_MemFree ( best ) ; len = MAXNAMELEN ; if ( RegQueryValueEx ( ver_key , " " , NULL , NULL , ( LPBYTE ) name , & len ) != ERROR_SUCCESS ) { if ( ver_key != NULL ) RegCloseKey ( ver_key ) ; return ( NULL ) ; } if ( ver_key != NULL ) RegCloseKey ( ver_key ) ; return ( JLI_StringDup ( name ) ) ; } }
Determine if there is an acceptable JRE in the registry directory top_key.
Determine if there is an acceptable JRE in the registry directory top_key .
/*
     * Enumerate "<top_key>/SOFTWARE/JavaSoft/Java Runtime Environment"
     * searching for the best available version.
     */ /*
     * Extract "JavaHome" from the "best" registry directory and return
     * that path.  If no appropriate version was located, or there is an
     * error in extracting the "JavaHome" string, return null.
     */