Changeset 7389 in vbox
- Timestamp:
- Mar 9, 2008 11:56:51 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/testcase/tstVBoxAPIWin.cpp
r5999 r7389 62 62 * First we have to get a list of all registered VMs 63 63 */ 64 IMachineCollection *collection = NULL; 65 IMachineEnumerator *enumerator = NULL; 64 SAFEARRAY *machinesArray = NULL; 66 65 67 do 66 rc = virtualBox->get_Machines2(&machinesArray); 67 if (SUCCEEDED(rc)) 68 68 { 69 rc = virtualBox->get_Machines(&collection); 70 if (SUCCEEDED(rc)) 71 rc = collection->Enumerate(&enumerator); 72 69 IMachine **machines; 70 rc = SafeArrayAccessData (machinesArray, (void **) &machines); 73 71 if (SUCCEEDED(rc)) 74 72 { 75 BOOL hasMore; 76 while (enumerator->HasMore(&hasMore), hasMore) 73 for (ULONG i = 0; i < machinesArray->rgsabound[0].cElements; ++i) 77 74 { 78 /* 79 * Get the machine object 80 */ 81 IMachine *machine = NULL; 82 rc = enumerator->GetNext(&machine); 75 BSTR str; 76 77 rc = machines[i]->get_Name(&str); 83 78 if (SUCCEEDED(rc)) 84 79 { 85 BSTR str;86 87 machine->get_Name(&str);88 80 printf("Name: %S\n", str); 89 90 81 SysFreeString(str); 91 92 machine->Release();93 82 } 94 83 } 84 85 SafeArrayUnaccessData (machinesArray); 95 86 } 96 } while (0);97 87 98 if (enumerator) 99 enumerator->Release(); 100 if (collection) 101 collection->Release(); 88 SafeArrayDestroy (machinesArray); 89 } 102 90 103 91 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.