Changeset 98297 in vbox for trunk/src/VBox/Main/cbinding
- Timestamp:
- Jan 25, 2023 1:59:25 AM (2 years ago)
- Location:
- trunk/src/VBox/Main/cbinding
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/cbinding/VBoxCAPI.cpp
r98103 r98297 229 229 #else /* !VBOX_WITH_XPCOM */ 230 230 VARTYPE vt = VT_UNKNOWN; 231 HRESULT rc = SafeArrayGetVartype(psa, &vt);232 if (FAILED( rc))233 return rc;231 HRESULT hrc = SafeArrayGetVartype(psa, &vt); 232 if (FAILED(hrc)) 233 return hrc; 234 234 if (vt == VT_BSTR) 235 235 { … … 238 238 * behavior between COM and XPCOM without this kind of trickery. */ 239 239 void *pData; 240 rc = SafeArrayAccessData(psa, &pData);241 if (FAILED( rc))242 return rc;240 hrc = SafeArrayAccessData(psa, &pData); 241 if (FAILED(hrc)) 242 return hrc; 243 243 ULONG cbElement = VBoxVTElemSize(vt); 244 244 if (!cbElement) … … 265 265 pData = psa->pv; 266 266 #else /* !VBOX_WITH_XPCOM */ 267 HRESULT rc = SafeArrayAccessData(psa, &pData);268 if (FAILED( rc))269 return rc;267 HRESULT hrc = SafeArrayAccessData(psa, &pData); 268 if (FAILED(hrc)) 269 return hrc; 270 270 #endif /* !VBOX_WITH_XPCOM */ 271 271 memcpy(pData, pv, cb); … … 305 305 cElements = psa->c; 306 306 #else /* !VBOX_WITH_XPCOM */ 307 HRESULT rc = SafeArrayAccessData(psa, &pData);308 if (FAILED( rc))307 HRESULT hrc = SafeArrayAccessData(psa, &pData); 308 if (FAILED(hrc)) 309 309 { 310 310 *ppv = NULL; 311 311 if (pcb) 312 312 *pcb = 0; 313 return rc;313 return hrc; 314 314 } 315 315 cElements = psa->rgsabound[0].cElements; … … 343 343 { 344 344 ULONG mypcb; 345 HRESULT rc = VBoxSafeArrayCopyOutParamHelper((void **)ppaObj, &mypcb, VT_UNKNOWN, psa);346 if (FAILED( rc))345 HRESULT hrc = VBoxSafeArrayCopyOutParamHelper((void **)ppaObj, &mypcb, VT_UNKNOWN, psa); 346 if (FAILED(hrc)) 347 347 { 348 348 if (pcObj) 349 349 *pcObj = 0; 350 return rc;350 return hrc; 351 351 } 352 352 ULONG cElements = mypcb / sizeof(void *); … … 404 404 sessionIID = IID_ISession; 405 405 406 HRESULT rc = com::Initialize(VBOX_COM_INIT_F_DEFAULT | VBOX_COM_INIT_F_NO_COM_PATCHING);407 if (FAILED( rc))408 { 409 Log(("Cbinding: COM/XPCOM could not be initialized! rc=%Rhrc\n",rc));406 HRESULT hrc = com::Initialize(VBOX_COM_INIT_F_DEFAULT | VBOX_COM_INIT_F_NO_COM_PATCHING); 407 if (FAILED(hrc)) 408 { 409 Log(("Cbinding: COM/XPCOM could not be initialized! hrc=%Rhrc\n", hrc)); 410 410 VBoxComUninitialize(); 411 411 return; … … 413 413 414 414 #ifdef VBOX_WITH_XPCOM 415 rc = NS_GetMainEventQ(&g_EventQueue);416 if (FAILED( rc))417 { 418 Log(("Cbinding: Could not get XPCOM event queue! rc=%Rhrc\n",rc));415 hrc = NS_GetMainEventQ(&g_EventQueue); 416 if (FAILED(hrc)) 417 { 418 Log(("Cbinding: Could not get XPCOM event queue! hrc=%Rhrc\n", hrc)); 419 419 VBoxComUninitialize(); 420 420 return; … … 424 424 #ifdef VBOX_WITH_XPCOM 425 425 nsIComponentManager *pManager; 426 rc = NS_GetComponentManager(&pManager);427 if (FAILED( rc))428 { 429 Log(("Cbinding: Could not get component manager! rc=%Rhrc\n",rc));426 hrc = NS_GetComponentManager(&pManager); 427 if (FAILED(hrc)) 428 { 429 Log(("Cbinding: Could not get component manager! hrc=%Rhrc\n", hrc)); 430 430 VBoxComUninitialize(); 431 431 return; 432 432 } 433 433 434 rc = pManager->CreateInstanceByContractID(NS_VIRTUALBOX_CONTRACTID,435 nsnull,436 virtualBoxIID,437 (void **)&g_VirtualBox);434 hrc = pManager->CreateInstanceByContractID(NS_VIRTUALBOX_CONTRACTID, 435 nsnull, 436 virtualBoxIID, 437 (void **)&g_VirtualBox); 438 438 #else /* !VBOX_WITH_XPCOM */ 439 439 IVirtualBoxClient *pVirtualBoxClient; 440 rc = CoCreateInstance(CLSID_VirtualBoxClient, NULL, CLSCTX_INPROC_SERVER, IID_IVirtualBoxClient, (void **)&pVirtualBoxClient);441 if (SUCCEEDED( rc))440 hrc = CoCreateInstance(CLSID_VirtualBoxClient, NULL, CLSCTX_INPROC_SERVER, IID_IVirtualBoxClient, (void **)&pVirtualBoxClient); 441 if (SUCCEEDED(hrc)) 442 442 { 443 443 IVirtualBox *pVirtualBox; 444 rc = pVirtualBoxClient->get_VirtualBox(&pVirtualBox);445 if (SUCCEEDED( rc))444 hrc = pVirtualBoxClient->get_VirtualBox(&pVirtualBox); 445 if (SUCCEEDED(hrc)) 446 446 { 447 rc = pVirtualBox->QueryInterface(virtualBoxIID, (void **)&g_VirtualBox);447 hrc = pVirtualBox->QueryInterface(virtualBoxIID, (void **)&g_VirtualBox); 448 448 pVirtualBox->Release(); 449 449 } … … 451 451 } 452 452 #endif /* !VBOX_WITH_XPCOM */ 453 if (FAILED( rc))454 { 455 Log(("Cbinding: Could not instantiate VirtualBox object! rc=%Rhrc\n",rc));453 if (FAILED(hrc)) 454 { 455 Log(("Cbinding: Could not instantiate VirtualBox object! hrc=%Rhrc\n",hrc)); 456 456 #ifdef VBOX_WITH_XPCOM 457 457 pManager->Release(); … … 465 465 466 466 #ifdef VBOX_WITH_XPCOM 467 rc = pManager->CreateInstanceByContractID(NS_SESSION_CONTRACTID, 468 nsnull, 469 sessionIID, 470 (void **)&g_Session); 467 hrc = pManager->CreateInstanceByContractID(NS_SESSION_CONTRACTID, nsnull, sessionIID, (void **)&g_Session); 471 468 #else /* !VBOX_WITH_XPCOM */ 472 rc = CoCreateInstance(CLSID_Session, NULL, CLSCTX_INPROC_SERVER, sessionIID, (void **)&g_Session);473 #endif /* !VBOX_WITH_XPCOM */ 474 if (FAILED( rc))475 { 476 Log(("Cbinding: Could not instantiate Session object! rc=%Rhrc\n",rc));469 hrc = CoCreateInstance(CLSID_Session, NULL, CLSCTX_INPROC_SERVER, sessionIID, (void **)&g_Session); 470 #endif /* !VBOX_WITH_XPCOM */ 471 if (FAILED(hrc)) 472 { 473 Log(("Cbinding: Could not instantiate Session object! hrc=%Rhrc\n",hrc)); 477 474 #ifdef VBOX_WITH_XPCOM 478 475 pManager->Release(); … … 568 565 VBoxGetException(IErrorInfo **ppException) 569 566 { 570 HRESULT rc;567 HRESULT hrc; 571 568 572 569 *ppException = NULL; … … 574 571 #ifdef VBOX_WITH_XPCOM 575 572 nsIServiceManager *mgr = NULL; 576 rc = NS_GetServiceManager(&mgr);577 if (FAILED( rc) || !mgr)578 return rc;573 hrc = NS_GetServiceManager(&mgr); 574 if (FAILED(hrc) || !mgr) 575 return hrc; 579 576 580 577 IID esid = NS_IEXCEPTIONSERVICE_IID; 581 578 nsIExceptionService *es = NULL; 582 rc = mgr->GetServiceByContractID(NS_EXCEPTIONSERVICE_CONTRACTID, esid, (void **)&es);583 if (FAILED( rc) || !es)579 hrc = mgr->GetServiceByContractID(NS_EXCEPTIONSERVICE_CONTRACTID, esid, (void **)&es); 580 if (FAILED(hrc) || !es) 584 581 { 585 582 mgr->Release(); 586 return rc;583 return hrc; 587 584 } 588 585 589 586 nsIExceptionManager *em; 590 rc = es->GetCurrentExceptionManager(&em);591 if (FAILED( rc) || !em)587 hrc = es->GetCurrentExceptionManager(&em); 588 if (FAILED(hrc) || !em) 592 589 { 593 590 es->Release(); 594 591 mgr->Release(); 595 return rc;592 return hrc; 596 593 } 597 594 598 595 nsIException *ex; 599 rc = em->GetCurrentException(&ex);600 if (FAILED( rc))596 hrc = em->GetCurrentException(&ex); 597 if (FAILED(hrc)) 601 598 { 602 599 em->Release(); 603 600 es->Release(); 604 601 mgr->Release(); 605 return rc;602 return hrc; 606 603 } 607 604 … … 612 609 #else /* !VBOX_WITH_XPCOM */ 613 610 IErrorInfo *ex; 614 rc = ::GetErrorInfo(0, &ex);615 if (FAILED( rc))616 return rc;611 hrc = ::GetErrorInfo(0, &ex); 612 if (FAILED(hrc)) 613 return hrc; 617 614 618 615 *ppException = ex; 619 616 #endif /* !VBOX_WITH_XPCOM */ 620 617 621 return rc;618 return hrc; 622 619 } 623 620 … … 625 622 VBoxClearException(void) 626 623 { 627 HRESULT rc;624 HRESULT hrc; 628 625 629 626 #ifdef VBOX_WITH_XPCOM 630 627 nsIServiceManager *mgr = NULL; 631 rc = NS_GetServiceManager(&mgr);632 if (FAILED( rc) || !mgr)633 return rc;628 hrc = NS_GetServiceManager(&mgr); 629 if (FAILED(hrc) || !mgr) 630 return hrc; 634 631 635 632 IID esid = NS_IEXCEPTIONSERVICE_IID; 636 633 nsIExceptionService *es = NULL; 637 rc = mgr->GetServiceByContractID(NS_EXCEPTIONSERVICE_CONTRACTID, esid, (void **)&es);638 if (FAILED( rc) || !es)634 hrc = mgr->GetServiceByContractID(NS_EXCEPTIONSERVICE_CONTRACTID, esid, (void **)&es); 635 if (FAILED(hrc) || !es) 639 636 { 640 637 mgr->Release(); 641 return rc;638 return hrc; 642 639 } 643 640 644 641 nsIExceptionManager *em; 645 rc = es->GetCurrentExceptionManager(&em);646 if (FAILED( rc) || !em)642 hrc = es->GetCurrentExceptionManager(&em); 643 if (FAILED(hrc) || !em) 647 644 { 648 645 es->Release(); 649 646 mgr->Release(); 650 return rc;651 } 652 653 rc = em->SetCurrentException(NULL);647 return hrc; 648 } 649 650 hrc = em->SetCurrentException(NULL); 654 651 em->Release(); 655 652 es->Release(); 656 653 mgr->Release(); 657 654 #else /* !VBOX_WITH_XPCOM */ 658 rc = ::SetErrorInfo(0, NULL);659 #endif /* !VBOX_WITH_XPCOM */ 660 661 return rc;655 hrc = ::SetErrorInfo(0, NULL); 656 #endif /* !VBOX_WITH_XPCOM */ 657 658 return hrc; 662 659 } 663 660 … … 679 676 virtualBoxClientIID = IID_IVirtualBoxClient; 680 677 681 HRESULT rc = com::Initialize(VBOX_COM_INIT_F_DEFAULT | VBOX_COM_INIT_F_NO_COM_PATCHING);682 if (FAILED( rc))683 { 684 Log(("Cbinding: COM/XPCOM could not be initialized! rc=%Rhrc\n",rc));678 HRESULT hrc = com::Initialize(VBOX_COM_INIT_F_DEFAULT | VBOX_COM_INIT_F_NO_COM_PATCHING); 679 if (FAILED(hrc)) 680 { 681 Log(("Cbinding: COM/XPCOM could not be initialized! hrc=%Rhrc\n", hrc)); 685 682 VBoxClientUninitialize(); 686 return rc;687 } 688 689 #ifdef VBOX_WITH_XPCOM 690 rc = NS_GetMainEventQ(&g_EventQueue);691 if (NS_FAILED( rc))692 { 693 Log(("Cbinding: Could not get XPCOM event queue! rc=%Rhrc\n",rc));683 return hrc; 684 } 685 686 #ifdef VBOX_WITH_XPCOM 687 hrc = NS_GetMainEventQ(&g_EventQueue); 688 if (NS_FAILED(hrc)) 689 { 690 Log(("Cbinding: Could not get XPCOM event queue! hrc=%Rhrc\n", hrc)); 694 691 VBoxClientUninitialize(); 695 return rc;692 return hrc; 696 693 } 697 694 #endif /* VBOX_WITH_XPCOM */ … … 699 696 #ifdef VBOX_WITH_XPCOM 700 697 nsIComponentManager *pManager; 701 rc = NS_GetComponentManager(&pManager);702 if (FAILED( rc))703 { 704 Log(("Cbinding: Could not get component manager! rc=%Rhrc\n",rc));698 hrc = NS_GetComponentManager(&pManager); 699 if (FAILED(hrc)) 700 { 701 Log(("Cbinding: Could not get component manager! hrc=%Rhrc\n", hrc)); 705 702 VBoxClientUninitialize(); 706 return rc;707 } 708 709 rc = pManager->CreateInstanceByContractID(NS_VIRTUALBOXCLIENT_CONTRACTID,710 nsnull,711 virtualBoxClientIID,712 (void **)ppVirtualBoxClient);703 return hrc; 704 } 705 706 hrc = pManager->CreateInstanceByContractID(NS_VIRTUALBOXCLIENT_CONTRACTID, 707 nsnull, 708 virtualBoxClientIID, 709 (void **)ppVirtualBoxClient); 713 710 #else /* !VBOX_WITH_XPCOM */ 714 rc = CoCreateInstance(CLSID_VirtualBoxClient, NULL, CLSCTX_INPROC_SERVER, virtualBoxClientIID, (void **)ppVirtualBoxClient);715 #endif /* !VBOX_WITH_XPCOM */ 716 if (FAILED( rc))717 { 718 Log(("Cbinding: Could not instantiate VirtualBoxClient object! rc=%Rhrc\n",rc));711 hrc = CoCreateInstance(CLSID_VirtualBoxClient, NULL, CLSCTX_INPROC_SERVER, virtualBoxClientIID, (void **)ppVirtualBoxClient); 712 #endif /* !VBOX_WITH_XPCOM */ 713 if (FAILED(hrc)) 714 { 715 Log(("Cbinding: Could not instantiate VirtualBoxClient object! hrc=%Rhrc\n",hrc)); 719 716 #ifdef VBOX_WITH_XPCOM 720 717 pManager->Release(); … … 722 719 #endif /* VBOX_WITH_XPCOM */ 723 720 VBoxClientUninitialize(); 724 return rc;721 return hrc; 725 722 } 726 723 -
trunk/src/VBox/Main/cbinding/tstCAPIGlue.c
r98103 r98297 136 136 { 137 137 VBoxEventType_T evType; 138 HRESULT rc;138 HRESULT hrc; 139 139 140 140 if (!event) … … 145 145 146 146 evType = VBoxEventType_Invalid; 147 rc = IEvent_get_Type(event, &evType);148 if (FAILED( rc))149 { 150 printf("cannot get event type, rc=%#x\n", (unsigned)rc);147 hrc = IEvent_get_Type(event, &evType); 148 if (FAILED(hrc)) 149 { 150 printf("cannot get event type, hrc=%#x\n", (unsigned)hrc); 151 151 return S_OK; 152 152 } … … 170 170 IStateChangedEvent *ev = NULL; 171 171 enum MachineState state; 172 rc = IEvent_QueryInterface(event, &IID_IStateChangedEvent, (void **)&ev);173 if (FAILED( rc))172 hrc = IEvent_QueryInterface(event, &IID_IStateChangedEvent, (void **)&ev); 173 if (FAILED(hrc)) 174 174 { 175 printf("cannot get StateChangedEvent interface, rc=%#x\n", (unsigned)rc);175 printf("cannot get StateChangedEvent interface, hrc=%#x\n", (unsigned)hrc); 176 176 return S_OK; 177 177 } … … 181 181 return S_OK; 182 182 } 183 rc = IStateChangedEvent_get_State(ev, &state);184 if (FAILED( rc))185 printf("warning: cannot get state, rc=%#x\n", (unsigned)rc);183 hrc = IStateChangedEvent_get_State(ev, &state); 184 if (FAILED(hrc)) 185 printf("warning: cannot get state, hrc=%#x\n", (unsigned)hrc); 186 186 IStateChangedEvent_Release(ev); 187 187 printf("OnStateChanged: %s\n", GetStateName(state)); … … 392 392 static HRESULT LoadTypeInfo(REFIID riid, ITypeInfo **pTInfo) 393 393 { 394 HRESULT rc;394 HRESULT hrc; 395 395 ITypeLib *pTypeLib; 396 rc = LoadRegTypeLib(&LIBID_VirtualBox, 1 /* major */, 0 /* minor */, 0 /* lcid */, &pTypeLib);397 if (FAILED( rc))398 return rc;399 rc = ITypeLib_GetTypeInfoOfGuid(pTypeLib, riid, pTInfo);396 hrc = LoadRegTypeLib(&LIBID_VirtualBox, 1 /* major */, 0 /* minor */, 0 /* lcid */, &pTypeLib); 397 if (FAILED(hrc)) 398 return hrc; 399 hrc = ITypeLib_GetTypeInfoOfGuid(pTypeLib, riid, pTInfo); 400 400 401 401 /* No longer need access to the type lib, release it. */ 402 402 ITypeLib_Release(pTypeLib); 403 403 404 return rc;404 return hrc; 405 405 } 406 406 #endif … … 465 465 { 466 466 IConsole *console = NULL; 467 HRESULT rc;468 469 rc = ISession_get_Console(session, &console);470 if ( (SUCCEEDED(rc)) && console)467 HRESULT hrc; 468 469 hrc = ISession_get_Console(session, &console); 470 if (SUCCEEDED(hrc) && console) 471 471 { 472 472 IEventSource *es = NULL; 473 rc = IConsole_get_EventSource(console, &es);474 if (SUCCEEDED( rc) && es)473 hrc = IConsole_get_EventSource(console, &es); 474 if (SUCCEEDED(hrc) && es) 475 475 { 476 476 static const ULONG s_auInterestingEvents[] = … … 514 514 IEventListenerDemo_AddRef(consoleListener); 515 515 516 rc = IEventSource_RegisterListener(es, (IEventListener *)consoleListener,517 ComSafeArrayAsInParam(interestingEventsSA),518 1 /* active */);519 if (SUCCEEDED( rc))516 hrc = IEventSource_RegisterListener(es, (IEventListener *)consoleListener, 517 ComSafeArrayAsInParam(interestingEventsSA), 518 1 /* active */); 519 if (SUCCEEDED(hrc)) 520 520 { 521 521 /* Just wait here for events, no easy way to do this better … … 569 569 { 570 570 IConsole *console = NULL; 571 HRESULT rc;572 573 rc = ISession_get_Console(session, &console);574 if (SUCCEEDED( rc) && console)571 HRESULT hrc; 572 573 hrc = ISession_get_Console(session, &console); 574 if (SUCCEEDED(hrc) && console) 575 575 { 576 576 IEventSource *es = NULL; 577 rc = IConsole_get_EventSource(console, &es);578 if (SUCCEEDED( rc) && es)577 hrc = IConsole_get_EventSource(console, &es); 578 if (SUCCEEDED(hrc) && es) 579 579 { 580 580 static const ULONG s_auInterestingEvents[] = … … 609 609 sizeof(s_auInterestingEvents)); 610 610 611 rc = IEventSource_CreateListener(es, &consoleListener);612 if (SUCCEEDED( rc) && consoleListener)611 hrc = IEventSource_CreateListener(es, &consoleListener); 612 if (SUCCEEDED(hrc) && consoleListener) 613 613 { 614 rc = IEventSource_RegisterListener(es, consoleListener,615 ComSafeArrayAsInParam(interestingEventsSA),616 0 /* passive */);617 if (SUCCEEDED( rc))614 hrc = IEventSource_RegisterListener(es, consoleListener, 615 ComSafeArrayAsInParam(interestingEventsSA), 616 0 /* passive */); 617 if (SUCCEEDED(hrc)) 618 618 { 619 619 /* Just wait here for events, no easy way to do this better … … 630 630 { 631 631 IEvent *ev = NULL; 632 rc = IEventSource_GetEvent(es, consoleListener, 250, &ev);633 if (FAILED( rc))632 hrc = IEventSource_GetEvent(es, consoleListener, 250, &ev); 633 if (FAILED(hrc)) 634 634 { 635 printf("Failed getting event: %#x\n", (unsigned) rc);635 printf("Failed getting event: %#x\n", (unsigned)hrc); 636 636 g_fStop = 1; 637 637 continue; … … 640 640 if (!ev) 641 641 continue; 642 rc = EventListenerDemoProcessEvent(ev);643 if (FAILED( rc))642 hrc = EventListenerDemoProcessEvent(ev); 643 if (FAILED(hrc)) 644 644 { 645 printf("Failed processing event: %#x\n", (unsigned) rc);645 printf("Failed processing event: %#x\n", (unsigned)hrc); 646 646 g_fStop = 1; 647 647 /* finish processing the event */ 648 648 } 649 rc = IEventSource_EventProcessed(es, consoleListener, ev);650 if (FAILED( rc))649 hrc = IEventSource_EventProcessed(es, consoleListener, ev); 650 if (FAILED(hrc)) 651 651 { 652 printf("Failed to mark event as processed: %#x\n", (unsigned) rc);652 printf("Failed to mark event as processed: %#x\n", (unsigned)hrc); 653 653 g_fStop = 1; 654 654 /* continue with event release */ … … 689 689 * @param pszExecutable string with the executable name 690 690 * @param pszErrorMsg string containing the code location specific error message 691 * @param rcCOM/XPCOM result code691 * @param hrc COM/XPCOM result code 692 692 */ 693 static void PrintErrorInfo(const char *pszExecutable, const char *pszErrorMsg, HRESULT rc)693 static void PrintErrorInfo(const char *pszExecutable, const char *pszErrorMsg, HRESULT hrc) 694 694 { 695 695 IErrorInfo *ex; 696 HRESULT rc2;697 fprintf(stderr, "%s: %s ( rc=%#010x)\n", pszExecutable, pszErrorMsg, (unsigned)rc);698 rc2 = g_pVBoxFuncs->pfnGetException(&ex);699 if (SUCCEEDED( rc2) && ex)696 HRESULT hrc2; 697 fprintf(stderr, "%s: %s (hrc=%#010x)\n", pszExecutable, pszErrorMsg, (unsigned)hrc); 698 hrc2 = g_pVBoxFuncs->pfnGetException(&ex); 699 if (SUCCEEDED(hrc2) && ex) 700 700 { 701 701 IVirtualBoxErrorInfo *ei; 702 rc2 = IErrorInfo_QueryInterface(ex, &IID_IVirtualBoxErrorInfo, (void **)&ei);703 if (SUCCEEDED( rc2) && ei != NULL)702 hrc2 = IErrorInfo_QueryInterface(ex, &IID_IVirtualBoxErrorInfo, (void **)&ei); 703 if (SUCCEEDED(hrc2) && ei != NULL) 704 704 { 705 705 /* got extended error info, maybe multiple infos */ … … 729 729 g_pVBoxFuncs->pfnUtf8Free(text); 730 730 731 rc2 = IVirtualBoxErrorInfo_get_Next(ei, &ei_next);732 if (FAILED( rc2))731 hrc2 = IVirtualBoxErrorInfo_get_Next(ei, &ei_next); 732 if (FAILED(hrc2)) 733 733 ei_next = NULL; 734 734 IVirtualBoxErrorInfo_Release(ei); … … 752 752 static void startVM(const char *argv0, IVirtualBox *virtualBox, ISession *session, BSTR id) 753 753 { 754 HRESULT rc;754 HRESULT hrc; 755 755 IMachine *machine = NULL; 756 756 IProgress *progress = NULL; … … 759 759 SAFEARRAY *groupsSA = g_pVBoxFuncs->pfnSafeArrayOutParamAlloc(); 760 760 761 rc = IVirtualBox_FindMachine(virtualBox, id, &machine);762 if (FAILED( rc) || !machine)763 { 764 PrintErrorInfo(argv0, "Error: Couldn't get the Machine reference", rc);761 hrc = IVirtualBox_FindMachine(virtualBox, id, &machine); 762 if (FAILED(hrc) || !machine) 763 { 764 PrintErrorInfo(argv0, "Error: Couldn't get the Machine reference", hrc); 765 765 return; 766 766 } 767 767 768 rc = IMachine_get_Groups(machine, ComSafeArrayAsOutTypeParam(groupsSA, BSTR));769 if (SUCCEEDED( rc))768 hrc = IMachine_get_Groups(machine, ComSafeArrayAsOutTypeParam(groupsSA, BSTR)); 769 if (SUCCEEDED(hrc)) 770 770 { 771 771 BSTR *groups = NULL; … … 792 792 793 793 g_pVBoxFuncs->pfnUtf8ToUtf16("gui", &sessionType); 794 rc = IMachine_LaunchVMProcess(machine, session, sessionType, ComSafeArrayAsInParam(env), &progress);794 hrc = IMachine_LaunchVMProcess(machine, session, sessionType, ComSafeArrayAsInParam(env), &progress); 795 795 g_pVBoxFuncs->pfnUtf16Free(sessionType); 796 if (SUCCEEDED( rc))796 if (SUCCEEDED(hrc)) 797 797 { 798 798 BOOL completed; … … 802 802 IProgress_WaitForCompletion(progress, -1); 803 803 804 rc = IProgress_get_Completed(progress, &completed);805 if (FAILED( rc))804 hrc = IProgress_get_Completed(progress, &completed); 805 if (FAILED(hrc)) 806 806 fprintf(stderr, "Error: GetCompleted status failed\n"); 807 807 … … 837 837 } 838 838 else 839 PrintErrorInfo(argv0, "Error: LaunchVMProcess failed", rc);839 PrintErrorInfo(argv0, "Error: LaunchVMProcess failed", hrc); 840 840 841 841 /* It's important to always release resources. */ … … 852 852 static void listVMs(const char *argv0, IVirtualBox *virtualBox, ISession *session) 853 853 { 854 HRESULT rc;854 HRESULT hrc; 855 855 SAFEARRAY *machinesSA = g_pVBoxFuncs->pfnSafeArrayOutParamAlloc(); 856 856 IMachine **machines = NULL; … … 862 862 * Get the list of all registered VMs. 863 863 */ 864 rc = IVirtualBox_get_Machines(virtualBox, ComSafeArrayAsOutIfaceParam(machinesSA, IMachine *));865 if (FAILED( rc))866 { 867 PrintErrorInfo(argv0, "could not get list of machines", rc);864 hrc = IVirtualBox_get_Machines(virtualBox, ComSafeArrayAsOutIfaceParam(machinesSA, IMachine *)); 865 if (FAILED(hrc)) 866 { 867 PrintErrorInfo(argv0, "could not get list of machines", hrc); 868 868 return; 869 869 } … … 1012 1012 BSTR versionUtf16 = NULL; 1013 1013 BSTR homefolderUtf16 = NULL; 1014 HRESULT rc; /* Result code of various function (method) calls. */1014 HRESULT hrc; /* Result code of various function (method) calls. */ 1015 1015 (void)argc; 1016 1016 … … 1040 1040 printf("----------------------------------------------------\n"); 1041 1041 1042 rc = IVirtualBoxClient_get_VirtualBox(vboxclient, &vbox);1043 if (FAILED( rc) || !vbox)1044 { 1045 PrintErrorInfo(argv[0], "FATAL: could not get VirtualBox reference", rc);1042 hrc = IVirtualBoxClient_get_VirtualBox(vboxclient, &vbox); 1043 if (FAILED(hrc) || !vbox) 1044 { 1045 PrintErrorInfo(argv[0], "FATAL: could not get VirtualBox reference", hrc); 1046 1046 return EXIT_FAILURE; 1047 1047 } 1048 rc = IVirtualBoxClient_get_Session(vboxclient, &session);1049 if (FAILED( rc) || !session)1050 { 1051 PrintErrorInfo(argv[0], "FATAL: could not get Session reference", rc);1048 hrc = IVirtualBoxClient_get_Session(vboxclient, &session); 1049 if (FAILED(hrc) || !session) 1050 { 1051 PrintErrorInfo(argv[0], "FATAL: could not get Session reference", hrc); 1052 1052 return EXIT_FAILURE; 1053 1053 } … … 1055 1055 #ifdef USE_ACTIVE_EVENT_LISTENER 1056 1056 # ifdef WIN32 1057 rc = LoadTypeInfo(&IID_IEventListener, &g_pTInfoIEventListener);1058 if (FAILED( rc) || !g_pTInfoIEventListener)1059 { 1060 PrintErrorInfo(argv[0], "FATAL: could not get type information for IEventListener", rc);1057 hrc = LoadTypeInfo(&IID_IEventListener, &g_pTInfoIEventListener); 1058 if (FAILED(hrc) || !g_pTInfoIEventListener) 1059 { 1060 PrintErrorInfo(argv[0], "FATAL: could not get type information for IEventListener", hrc); 1061 1061 return EXIT_FAILURE; 1062 1062 } … … 1071 1071 1072 1072 /* 1. Revision */ 1073 rc = IVirtualBox_get_Revision(vbox, &revision);1074 if (SUCCEEDED( rc))1073 hrc = IVirtualBox_get_Revision(vbox, &revision); 1074 if (SUCCEEDED(hrc)) 1075 1075 printf("\tRevision: %u\n", (unsigned)revision); 1076 1076 else 1077 PrintErrorInfo(argv[0], "GetRevision() failed", rc);1077 PrintErrorInfo(argv[0], "GetRevision() failed", hrc); 1078 1078 1079 1079 /* 2. Version */ 1080 rc = IVirtualBox_get_Version(vbox, &versionUtf16);1081 if (SUCCEEDED( rc))1080 hrc = IVirtualBox_get_Version(vbox, &versionUtf16); 1081 if (SUCCEEDED(hrc)) 1082 1082 { 1083 1083 char *version = NULL; … … 1088 1088 } 1089 1089 else 1090 PrintErrorInfo(argv[0], "GetVersion() failed", rc);1090 PrintErrorInfo(argv[0], "GetVersion() failed", hrc); 1091 1091 1092 1092 /* 3. Home Folder */ 1093 rc = IVirtualBox_get_HomeFolder(vbox, &homefolderUtf16);1094 if (SUCCEEDED( rc))1093 hrc = IVirtualBox_get_HomeFolder(vbox, &homefolderUtf16); 1094 if (SUCCEEDED(hrc)) 1095 1095 { 1096 1096 char *homefolder = NULL; … … 1101 1101 } 1102 1102 else 1103 PrintErrorInfo(argv[0], "GetHomeFolder() failed", rc);1103 PrintErrorInfo(argv[0], "GetHomeFolder() failed", hrc); 1104 1104 1105 1105 listVMs(argv[0], vbox, session);
Note:
See TracChangeset
for help on using the changeset viewer.