Changeset 22840 in vbox for trunk/src/VBox/Additions/common/VBoxService
- Timestamp:
- Sep 8, 2009 1:33:06 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceVMInfo-win.cpp
r22728 r22840 337 337 338 338 HKEY hKey = NULL; 339 long rc = 0;339 int rc; 340 340 DWORD dwSize = 0; 341 341 DWORD dwType = 0; … … 344 344 345 345 /* Check the new path first. */ 346 rc = RegOpenKeyExA (HKEY_LOCAL_MACHINE, "SOFTWARE\\Sun\\VirtualBox Guest Additions", 0, KEY_READ, &hKey); 346 rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Sun\\VirtualBox Guest Additions", 0, KEY_READ, &hKey); 347 #ifdef RT_ARCH_AMD64 347 348 if (rc != ERROR_SUCCESS) 348 349 { 349 VBoxServiceVerbose(3, "Guest Additions version lookup: Looking in xVM key ...\n"); 350 351 /* New path does not exist, check the old one ... */ 352 rc = RegOpenKeyExA (HKEY_LOCAL_MACHINE, "SOFTWARE\\Sun\\xVM VirtualBox Guest Additions", 0, KEY_READ, &hKey); 350 /* Check Wow6432Node (for new entries). */ 351 rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Wow6432Node\\Sun\\VirtualBox Guest Additions", 0, KEY_READ, &hKey); 352 } 353 #endif 354 355 /* Still no luck? Then try the old xVM paths ... */ 356 if (RT_FAILURE(rc)) 357 { 358 rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Sun\\xVM VirtualBox Guest Additions", 0, KEY_READ, &hKey); 359 #ifdef RT_ARCH_AMD64 353 360 if (rc != ERROR_SUCCESS) 354 361 { 355 /* Nothing seems to exist, print some warning. */ 356 VBoxServiceError("Failed to open registry key (guest additions)! Error: %d\n", rc); 357 return 1; 358 } 359 } 360 361 VBoxServiceVerbose(3, "Guest Additions version lookup: Key: 0x%p, RC: %d\n", hKey, rc); 362 363 /* Installation directory. */ 364 dwSize = sizeof(szInstDir); 365 rc = RegQueryValueExA (hKey, "InstallDir", NULL, &dwType, (BYTE*)(LPCTSTR)szInstDir, &dwSize); 366 if ((rc != ERROR_SUCCESS) && (rc != ERROR_FILE_NOT_FOUND)) 367 { 368 RegCloseKey (hKey); 369 VBoxServiceError("Failed to query registry key (install directory)! Error: %d\n", rc); 370 return 1; 371 } 372 373 /* Flip slashes. */ 374 for (char* pszTmp = &szInstDir[0]; *pszTmp; ++pszTmp) 375 if (*pszTmp == '\\') 376 *pszTmp = '/'; 377 378 /* Revision. */ 379 dwSize = sizeof(szRev); 380 rc = RegQueryValueExA (hKey, "Revision", NULL, &dwType, (BYTE*)(LPCTSTR)szRev, &dwSize); 381 if ((rc != ERROR_SUCCESS) && (rc != ERROR_FILE_NOT_FOUND)) 382 { 383 RegCloseKey (hKey); 384 VBoxServiceError("Failed to query registry key (revision)! Error: %d\n", rc); 385 return 1; 386 } 387 388 /* Version. */ 389 dwSize = sizeof(szVer); 390 rc = RegQueryValueExA (hKey, "Version", NULL, &dwType, (BYTE*)(LPCTSTR)szVer, &dwSize); 391 if ((rc != ERROR_SUCCESS) && (rc != ERROR_FILE_NOT_FOUND)) 392 { 393 RegCloseKey (hKey); 394 VBoxServiceError("Failed to query registry key (version)! Error: %u\n", rc); 395 return 1; 362 /* Check Wow6432Node (for new entries). */ 363 rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Wow6432Node\\Sun\\xVM VirtualBox Guest Additions", 0, KEY_READ, &hKey); 364 } 365 #endif 366 } 367 368 /* Did we get something worth looking at? */ 369 if (RT_FAILURE(rc)) 370 { 371 VBoxServiceError("Failed to open registry key (guest additions)! Error: %Rrc\n", rc); 372 } 373 else 374 { 375 VBoxServiceVerbose(3, "Guest Additions version lookup: Key: 0x%p, rc: %Rrc\n", hKey, rc); 376 /* Installation directory. */ 377 dwSize = sizeof(szInstDir); 378 rc = RegQueryValueEx(hKey, "InstallDir", NULL, &dwType, (BYTE*)(LPCTSTR)szInstDir, &dwSize); 379 if ((rc != ERROR_SUCCESS) && (rc != ERROR_FILE_NOT_FOUND)) 380 { 381 VBoxServiceError("Failed to query registry key (install directory)! Error: %Rrc\n", rc); 382 } 383 else 384 { 385 /* Flip slashes. */ 386 for (char* pszTmp = &szInstDir[0]; *pszTmp; ++pszTmp) 387 if (*pszTmp == '\\') 388 *pszTmp = '/'; 389 } 390 /* Revision. */ 391 dwSize = sizeof(szRev); 392 rc = RegQueryValueEx(hKey, "Revision", NULL, &dwType, (BYTE*)(LPCTSTR)szRev, &dwSize); 393 if ((rc != ERROR_SUCCESS) && (rc != ERROR_FILE_NOT_FOUND)) 394 VBoxServiceError("Failed to query registry key (revision)! Error: %Rrc\n", rc); 395 /* Version. */ 396 dwSize = sizeof(szVer); 397 rc = RegQueryValueEx(hKey, "Version", NULL, &dwType, (BYTE*)(LPCTSTR)szVer, &dwSize); 398 if ((rc != ERROR_SUCCESS) && (rc != ERROR_FILE_NOT_FOUND)) 399 VBoxServiceError("Failed to query registry key (version)! Error: %Rrc\n", rc); 396 400 } 397 401 … … 401 405 VboxServiceWriteProp(uiClientID, "GuestAdd/Version", szVer); 402 406 403 RegCloseKey (hKey); 404 405 return VINF_SUCCESS; 407 if (NULL != hKey) 408 RegCloseKey(hKey); 409 410 return rc; 406 411 } 407 412
Note:
See TracChangeset
for help on using the changeset viewer.