emulator: Fixed a bug Java path not found on Windows 64
authorjinhyung.jo <jinhyung.jo@samsung.com>
Wed, 2 Sep 2015 05:51:14 +0000 (14:51 +0900)
committerSeokYeon Hwang <syeon.hwang@samsung.com>
Wed, 2 Sep 2015 09:29:37 +0000 (18:29 +0900)
The get_java_path function aways returns the first item of the JRE(or JDK) registry.
The RegEnumKeyEx function's 4th argument type is [In, Out],
But previous implementations have used without resetting it.
So fix it and improved the 'while' statement.

Change-Id: Ief77879c1b6be8f02fbc36e5c7d118152984e371
Signed-off-by: Jinhyung Jo <jinhyung.jo@samsung.com>
util/oslib-win32.c

index 9149fa64e018a3075fe51a29494328bcefd44603..2c855166f6cf75367a520dc5b8826396d17af923 100644 (file)
@@ -105,20 +105,18 @@ bool get_java_path(char **java_path)
     }
 
     if (res == ERROR_SUCCESS) {
-        RegEnumKeyEx(hKey, 0, (LPSTR)strSubKeyName, &dwSubKeyNameMax,
-                     NULL, NULL, NULL, NULL);
-        strcpy(strChoosenName, strSubKeyName);
-
-        index = 1;
-        while (ERROR_SUCCESS ==
-                RegEnumKeyEx(hKey, index,
-                             (LPSTR)strSubKeyName, &dwSubKeyNameMax,
-                             NULL, NULL, NULL, NULL)) {
+        index = 0;
+        do {
+            dwSubKeyNameMax = JAVA_MAX_COMMAND_LENGTH;
+            res = RegEnumKeyEx(hKey,
+                               index++,
+                               (LPSTR)strSubKeyName,
+                               &dwSubKeyNameMax,
+                               NULL, NULL, NULL, NULL);
             if (strcmp(strChoosenName, strSubKeyName) < 0) {
                 strcpy(strChoosenName, strSubKeyName);
             }
-            index++;
-        }
+        } while (res == ERROR_SUCCESS);
 
         RegOpenKeyEx(hKey, strChoosenName, 0,
                      KEY_QUERY_VALUE | MY_KEY_WOW64_64KEY, &hSubKey);