Index: trunk/src/VBox/Additions/common/VBoxService/VBoxServiceVMInfo-win.cpp
===================================================================
--- trunk/src/VBox/Additions/common/VBoxService/VBoxServiceVMInfo-win.cpp	(revision 20658)
+++ trunk/src/VBox/Additions/common/VBoxService/VBoxServiceVMInfo-win.cpp	(revision 20698)
@@ -182,5 +182,5 @@
     if (r != STATUS_SUCCESS)
     {
-        VBoxServiceError("LsaGetLogonSessionData failed %lu\n", LsaNtStatusToWinError(r));
+        VBoxServiceError("LsaGetLogonSessionData failed, LSA error %lu\n", LsaNtStatusToWinError(r));
 
         if (sessionData)
@@ -196,5 +196,5 @@
     }
 
-    VBoxServiceVerbose(3, "vboxVMInfoThread: Users: Session data: Name = %ls, Len = %d, SID = %s, LogonID = %d,%d\n", 
+    VBoxServiceVerbose(3, "Users: Session data: Name = %ls, Len = %d, SID = %s, LogonID = %d,%d\n", 
         (sessionData->UserName).Buffer, (sessionData->UserName).Length, (sessionData->Sid != NULL) ? "1" : "0", sessionData->LogonId.HighPart, sessionData->LogonId.LowPart);
 
@@ -281,5 +281,5 @@
                         &dwBytesRet))
                     {
-                        /*VBoxServiceVerbose(3, ("vboxVMInfoThread: Users: WTSQuerySessionInformation returned %ld bytes, p=%p, state=%d\n", dwBytesRet, pBuffer, pBuffer != NULL ? (INT)*pBuffer : -1));*/
+                        /*VBoxServiceVerbose(3, ("Users: WTSQuerySessionInformation returned %ld bytes, p=%p, state=%d\n", dwBytesRet, pBuffer, pBuffer != NULL ? (INT)*pBuffer : -1));*/
                         if(dwBytesRet)
                             iState = *pBuffer;
@@ -291,5 +291,5 @@
                             /** @todo On Vista and W2K, always "old" user name are still
                              *        there. Filter out the old one! */
-                            VBoxServiceVerbose(3, "vboxVMInfoThread: Users: Account User=%ls is logged in via TCS/RDP. State=%d\n", a_pUserInfo->szUser, iState);
+                            VBoxServiceVerbose(3, "Users: Account User=%ls is logged in via TCS/RDP. State=%d\n", a_pUserInfo->szUser, iState);
                             bFoundUser = TRUE;
                         }
@@ -333,14 +333,17 @@
 
     HKEY hKey = NULL;
-    int rc = 0;
+    long rc = 0;
     DWORD dwSize = 0;
-
+    DWORD dwType = 0;
+
+    /* First try the old registry path ... */
     rc = RegOpenKeyExA (HKEY_LOCAL_MACHINE, "SOFTWARE\\Sun\\xVM VirtualBox Guest Additions", 0, KEY_READ, &hKey);
-    if ((rc != ERROR_SUCCESS ) && (rc != ERROR_FILE_NOT_FOUND))
-    {
+    if ((rc != ERROR_SUCCESS) && (rc != ERROR_FILE_NOT_FOUND))
+    {
+        /* Old registry path does not exist -- maybe the new one does? */
         rc = RegOpenKeyExA (HKEY_LOCAL_MACHINE, "SOFTWARE\\Sun\\VirtualBox Guest Additions", 0, KEY_READ, &hKey);
-        if ((rc != ERROR_SUCCESS ) && (rc != ERROR_FILE_NOT_FOUND))
-        {
-            VBoxServiceError("Failed to open registry key (guest additions)! Error: %d\n", GetLastError());
+        if ((rc != ERROR_SUCCESS) && (rc != ERROR_FILE_NOT_FOUND))
+        {
+            VBoxServiceError("Failed to open registry key (guest additions)! Error: %d\n", rc);
             return 1;
         }
@@ -349,9 +352,9 @@
     /* Installation directory. */
     dwSize = sizeof(szInstDir);
-    rc = RegQueryValueExA (hKey, "InstallDir", 0, 0, (BYTE*)(LPCTSTR)szInstDir, &dwSize);
-    if ((rc != ERROR_SUCCESS ) && (rc != ERROR_FILE_NOT_FOUND))
+    rc = RegQueryValueExA (hKey, "InstallDir", NULL, &dwType, (BYTE*)(LPCTSTR)szInstDir, &dwSize);
+    if ((rc != ERROR_SUCCESS) && (rc != ERROR_FILE_NOT_FOUND))
     {
         RegCloseKey (hKey);
-        VBoxServiceError("Failed to query registry key (install directory)! Error: %d\n", GetLastError());
+        VBoxServiceError("Failed to query registry key (install directory)! Error: %d\n", rc);
         return 1;
     }
@@ -364,9 +367,9 @@
     /* Revision. */
     dwSize = sizeof(szRev);
-    rc = RegQueryValueExA (hKey, "Revision", 0, 0, (BYTE*)(LPCTSTR)szRev, &dwSize);
-    if ((rc != ERROR_SUCCESS ) && (rc != ERROR_FILE_NOT_FOUND))
+    rc = RegQueryValueExA (hKey, "Revision", NULL, &dwType, (BYTE*)(LPCTSTR)szRev, &dwSize);
+    if ((rc != ERROR_SUCCESS) && (rc != ERROR_FILE_NOT_FOUND))
     {
         RegCloseKey (hKey);
-        VBoxServiceError("Failed to query registry key (revision)! Error: %d\n",  GetLastError());
+        VBoxServiceError("Failed to query registry key (revision)! Error: %d\n",  rc);
         return 1;
     }
@@ -374,9 +377,9 @@
     /* Version. */
     dwSize = sizeof(szVer);
-    rc = RegQueryValueExA (hKey, "Version", 0, 0, (BYTE*)(LPCTSTR)szVer, &dwSize);
-    if ((rc != ERROR_SUCCESS ) && (rc != ERROR_FILE_NOT_FOUND))
+    rc = RegQueryValueExA (hKey, "Version", NULL, &dwType, (BYTE*)(LPCTSTR)szVer, &dwSize);
+    if ((rc != ERROR_SUCCESS) && (rc != ERROR_FILE_NOT_FOUND))
     {
         RegCloseKey (hKey);
-        VBoxServiceError("Failed to query registry key (version)! Error: %Rrc\n",  GetLastError());
+        VBoxServiceError("Failed to query registry key (version)! Error: %Rrc\n",  rc);
         return 1;
     }
