VirtualBox

Changeset 2459 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
May 3, 2007 9:40:33 AM (18 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
20872
Message:

added IErrorInfo testcase

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/testcase/tstVBoxAPIWin.cpp

    r1 r2459  
    8080}
    8181
     82int testErrorInfo(IVirtualBox *virtualBox)
     83{
     84    HRESULT rc;
     85
     86    /* try to find a machine that doesn't exist */
     87    IMachine *machine = NULL;
     88    BSTR machineName = SysAllocString(L"Foobar");
     89
     90    rc = virtualBox->FindMachine(machineName, &machine);
     91
     92    if (FAILED(rc))
     93    {
     94        IErrorInfo *errorInfo;
     95
     96        rc = GetErrorInfo(0, &errorInfo);
     97
     98        if (FAILED(rc))
     99            printf("Error getting error info! rc = 0x%x\n", rc);
     100        else
     101        {
     102            BSTR errorDescription = NULL;
     103
     104            rc = errorInfo->GetDescription(&errorDescription);
     105
     106            if (FAILED(rc) || !errorDescription)
     107                printf("Error getting error description! rc = 0x%x\n", rc);
     108            else
     109            {
     110                printf("Successfully retrieved error description: %S\n", errorDescription);
     111
     112                SysFreeString(errorDescription);
     113            }
     114
     115            errorInfo->Release();
     116        }
     117    }
     118
     119    if (machine)
     120        machine->Release();
     121
     122    SysFreeString(machineName);
     123
     124    return 0;
     125}
     126
    82127
    83128int main(int argc, char *argv[])
     
    106151        listVMs(virtualBox);
    107152
     153        testErrorInfo(virtualBox);
    108154
    109155        /* release the VirtualBox object */
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette