- Timestamp:
- Oct 18, 2010 8:03:11 AM (14 years ago)
- svn:sync-xref-src-repo-rev:
- 66717
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/Installer/VBoxDrvInst.cpp
r32622 r33181 361 361 int InstallDriver (_TCHAR* a_pszInfFile, _TCHAR* a_pszHwID, _TCHAR* a_pszDevClass) 362 362 { 363 int rc = EXIT_OK; /** @todo Use IPRT values! */ 364 363 365 DWORD dwErr = 0; 364 366 BOOL bReboot = FALSE; … … 378 380 { 379 381 _tprintf(_T("Could not retrieve device class GUID! Error: %ld\n"), GetLastError()); 380 r eturnEXIT_FAIL;382 rc = EXIT_FAIL; 381 383 } 382 384 else … … 398 400 } 399 401 400 _TCHAR* pcFile = NULL; 401 if (0 == GetFullPathName(a_pszInfFile, _MAX_PATH, szInf, &pcFile)) 402 { 403 dwErr = GetLastError(); 404 405 _tprintf(_T("ERROR: INF-Path too long / could not be retrieved!\n")); 406 return EXIT_FAIL; 407 } 408 409 /* Extract path from path+INF */ 410 if (pcFile != NULL) 411 _tcsnccpy(szInfPath, szInf, pcFile - szInf); 412 413 _tprintf(_T("INF-File: %ws\n"), szInf); 414 _tprintf(_T("INF-Path: %ws\n"), szInfPath); 415 416 _tprintf(_T("Updating driver for plug'n play devices ...\n")); 417 if (!g_pfnUpdateDriverForPlugAndPlayDevices(NULL, a_pszHwID, szInf, INSTALLFLAG_FORCE, &bReboot)) 418 { 419 DWORD dwErr = GetLastError(); 420 _TCHAR szErrMsg[_MAX_PATH + 1] = { 0 }; 421 422 if (dwErr == ERROR_NO_SUCH_DEVINST) 423 { 424 _TCHAR szDestInf[_MAX_PATH] = { 0 }; 425 _tprintf(_T("The device is not plugged in (yet), pre-installing drivers ...\n")); 426 427 if (FALSE == g_pfnSetupCopyOEMInf(szInf, szInfPath, SPOST_PATH, 0, szDestInf, sizeof(szDestInf), NULL, NULL)) 428 { 429 dwErr = GetLastError(); 430 GetErrorMsg(dwErr, szErrMsg, sizeof(szErrMsg)); 431 _tprintf(_T("ERROR (%08x): %ws\n"), dwErr, szErrMsg); 432 return EXIT_FAIL; 433 } 434 435 _tprintf(_T("OK. Installed to: %ws\n"), szDestInf); 436 return EXIT_OK; 437 } 438 439 switch (dwErr) 440 { 441 442 case ERROR_INVALID_FLAGS: 443 444 _tprintf(_T("ERROR: The value specified for InstallFlags is invalid!\n")); 445 break; 446 447 case ERROR_NO_MORE_ITEMS: 448 449 _tprintf( 450 _T( 451 "ERROR: The function found a match for the HardwareId value, but the specified driver was not a better match than the current driver and the caller did not specify the INSTALLFLAG_FORCE flag!\n")); 452 break; 453 454 case ERROR_FILE_NOT_FOUND: 455 456 _tprintf(_T("ERROR: File not found!\n")); 457 break; 458 459 case ERROR_IN_WOW64: 460 461 _tprintf(_T("ERROR: The calling application is a 32-bit application attempting to execute in a 64-bit environment, which is not allowed!")); 462 break; 463 464 case ERROR_NO_DRIVER_SELECTED: 465 466 _tprintf(_T("ERROR: No driver in .INF-file selected!\n")); 467 break; 468 469 case ERROR_SECTION_NOT_FOUND: 470 471 _tprintf(_T("ERROR: Section in .INF-file was not found!\n")); 472 break; 473 474 default: 475 476 /* Try error lookup with GetErrorMsg() */ 477 GetErrorMsg(dwErr, szErrMsg, sizeof(szErrMsg)); 478 _tprintf(_T("ERROR (%08x): %ws\n"), dwErr, szErrMsg); 479 break; 480 } 481 482 return EXIT_FAIL; 483 } 484 485 _tprintf(_T("Installation successful.\n")); 486 487 return EXIT_OK; 402 if (rc == EXIT_OK) 403 { 404 _TCHAR* pcFile = NULL; 405 if (0 == GetFullPathName(a_pszInfFile, _MAX_PATH, szInf, &pcFile)) 406 { 407 dwErr = GetLastError(); 408 409 _tprintf(_T("ERROR: INF-Path too long / could not be retrieved!\n")); 410 rc = EXIT_FAIL; 411 } 412 413 /* Extract path from path+INF */ 414 if (pcFile != NULL) 415 _tcsnccpy(szInfPath, szInf, pcFile - szInf); 416 417 _tprintf(_T("INF-File: %ws\n"), szInf); 418 _tprintf(_T("INF-Path: %ws\n"), szInfPath); 419 420 _tprintf(_T("Updating driver for plug'n play devices ...\n")); 421 if (!g_pfnUpdateDriverForPlugAndPlayDevices(NULL, a_pszHwID, szInf, INSTALLFLAG_FORCE, &bReboot)) 422 { 423 DWORD dwErr = GetLastError(); 424 _TCHAR szErrMsg[_MAX_PATH + 1] = { 0 }; 425 426 if (dwErr == ERROR_NO_SUCH_DEVINST) 427 { 428 _TCHAR szDestInf[_MAX_PATH] = { 0 }; 429 _tprintf(_T("The device is not plugged in (yet), pre-installing drivers ...\n")); 430 431 if (FALSE == g_pfnSetupCopyOEMInf(szInf, szInfPath, SPOST_PATH, 0, szDestInf, sizeof(szDestInf), NULL, NULL)) 432 { 433 dwErr = GetLastError(); 434 GetErrorMsg(dwErr, szErrMsg, sizeof(szErrMsg)); 435 _tprintf(_T("ERROR (%08x): %ws\n"), dwErr, szErrMsg); 436 437 rc = EXIT_FAIL; 438 } 439 else 440 _tprintf(_T("OK. Installed to: %ws\n"), szDestInf); 441 } 442 else 443 { 444 switch (dwErr) 445 { 446 447 case ERROR_INVALID_FLAGS: 448 449 _tprintf(_T("ERROR: The value specified for InstallFlags is invalid!\n")); 450 break; 451 452 case ERROR_NO_MORE_ITEMS: 453 454 _tprintf( 455 _T( 456 "ERROR: The function found a match for the HardwareId value, but the specified driver was not a better match than the current driver and the caller did not specify the INSTALLFLAG_FORCE flag!\n")); 457 break; 458 459 case ERROR_FILE_NOT_FOUND: 460 461 _tprintf(_T("ERROR: File not found! File = %ws\n", szInf)); 462 break; 463 464 case ERROR_IN_WOW64: 465 466 _tprintf(_T("ERROR: The calling application is a 32-bit application attempting to execute in a 64-bit environment, which is not allowed!")); 467 break; 468 469 case ERROR_NO_DRIVER_SELECTED: 470 471 _tprintf(_T("ERROR: No driver in .INF-file selected!\n")); 472 break; 473 474 case ERROR_SECTION_NOT_FOUND: 475 476 _tprintf(_T("ERROR: Section in .INF-file was not found!\n")); 477 break; 478 479 default: 480 481 /* Try error lookup with GetErrorMsg() */ 482 GetErrorMsg(dwErr, szErrMsg, sizeof(szErrMsg)); 483 _tprintf(_T("ERROR (%08x): %ws\n"), dwErr, szErrMsg); 484 break; 485 } 486 487 rc = EXIT_FAIL; 488 } 489 } 490 } 491 492 if (rc == EXIT_OK) 493 _tprintf(_T("Installation successful.\n")); 494 return rc; 488 495 } 489 496
Note:
See TracChangeset
for help on using the changeset viewer.