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)
committerJinhyung Jo <jinhyung.jo@samsung.com>
Fri, 11 Sep 2015 07:42:51 +0000 (16:42 +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>
(cherry picked from commit 812b3ccac697ae0d026bb7ea911b95aaa7f04921)

util/oslib-win32.c

index b5beed56eef42c6c6135beb219d629b8fb4a7dc5..22bdb0b212a8450f6b152243c9d518df38d29081 100644 (file)
@@ -101,20 +101,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);