Changeset 20928 in vbox for trunk/src/VBox/Main/testcase
- Timestamp:
- Jun 25, 2009 11:53:37 AM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 49096
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/testcase/tstAPI.cpp
r19239 r20928 5 5 6 6 /* 7 * Copyright (C) 2006-200 7Sun Microsystems, Inc.7 * Copyright (C) 2006-2009 Sun Microsystems, Inc. 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 28 28 #include <VBox/com/Guid.h> 29 29 #include <VBox/com/ErrorInfo.h> 30 #include <VBox/com/errorprint _legacy.h>30 #include <VBox/com/errorprint.h> 31 31 #include <VBox/com/EventQueue.h> 32 32 … … 45 45 #include <iprt/stream.h> 46 46 #include <iprt/thread.h> 47 48 #define printf RTPrintf49 47 50 48 … … 68 66 69 67 Bstr name; 70 printf ("Getting machine name...\n");71 CHECK_ RC_RET (machine->COMGETTER(Name) (name.asOutParam()));72 printf ("Name: {%ls}\n", name.raw());73 74 printf("Getting machine GUID...\n");75 Bstr guid; 76 CHECK_ RC (machine->COMGETTER(Id) (guid.asOutParam()));68 RTPrintf ("Getting machine name...\n"); 69 CHECK_ERROR_RET (machine, COMGETTER(Name) (name.asOutParam()), rc); 70 RTPrintf ("Name: {%ls}\n", name.raw()); 71 72 RTPrintf("Getting machine GUID...\n"); 73 Bstr guid; 74 CHECK_ERROR (machine, COMGETTER(Id) (guid.asOutParam())); 77 75 if (SUCCEEDED (rc) && !guid.isEmpty()) { 78 printf ("Guid::toString(): {%s}\n", Utf8Str(guid).c_str());76 RTPrintf ("Guid::toString(): {%s}\n", Utf8Str(guid).c_str()); 79 77 } else { 80 printf ("WARNING: there's no GUID!");78 RTPrintf ("WARNING: there's no GUID!"); 81 79 } 82 80 83 81 ULONG memorySize; 84 printf ("Getting memory size...\n");85 CHECK_ RC_RET (machine->COMGETTER(MemorySize) (&memorySize));86 printf ("Memory size: %d\n", memorySize);82 RTPrintf ("Getting memory size...\n"); 83 CHECK_ERROR_RET (machine, COMGETTER(MemorySize) (&memorySize), rc); 84 RTPrintf ("Memory size: %d\n", memorySize); 87 85 88 86 MachineState_T machineState; 89 printf ("Getting machine state...\n");90 CHECK_ RC_RET (machine->COMGETTER(State) (&machineState));91 printf ("Machine state: %d\n", machineState);87 RTPrintf ("Getting machine state...\n"); 88 CHECK_ERROR_RET (machine, COMGETTER(State) (&machineState), rc); 89 RTPrintf ("Machine state: %d\n", machineState); 92 90 93 91 BOOL modified; 94 printf ("Are any settings modified?...\n");95 CHECK_ RC (machine->COMGETTER(SettingsModified) (&modified));92 RTPrintf ("Are any settings modified?...\n"); 93 CHECK_ERROR (machine, COMGETTER(SettingsModified) (&modified)); 96 94 if (SUCCEEDED (rc)) 97 printf ("%s\n", modified ? "yes" : "no");95 RTPrintf ("%s\n", modified ? "yes" : "no"); 98 96 99 97 ULONG memorySizeBig = memorySize * 10; 100 printf("Changing memory size to %d...\n", memorySizeBig);101 CHECK_ RC (machine->COMSETTER(MemorySize) (memorySizeBig));98 RTPrintf("Changing memory size to %d...\n", memorySizeBig); 99 CHECK_ERROR (machine, COMSETTER(MemorySize) (memorySizeBig)); 102 100 103 101 if (SUCCEEDED (rc)) 104 102 { 105 printf ("Are any settings modified now?...\n");106 CHECK_ RC_RET (machine->COMGETTER(SettingsModified) (&modified));107 printf ("%s\n", modified ? "yes" : "no");103 RTPrintf ("Are any settings modified now?...\n"); 104 CHECK_ERROR_RET (machine, COMGETTER(SettingsModified) (&modified), rc); 105 RTPrintf ("%s\n", modified ? "yes" : "no"); 108 106 ASSERT_RET (modified, 0); 109 107 110 108 ULONG memorySizeGot; 111 printf ("Getting memory size again...\n");112 CHECK_ RC_RET (machine->COMGETTER(MemorySize) (&memorySizeGot));113 printf ("Memory size: %d\n", memorySizeGot);109 RTPrintf ("Getting memory size again...\n"); 110 CHECK_ERROR_RET (machine, COMGETTER(MemorySize) (&memorySizeGot), rc); 111 RTPrintf ("Memory size: %d\n", memorySizeGot); 114 112 ASSERT_RET (memorySizeGot == memorySizeBig, 0); 115 113 116 114 if (readonlyMachine) 117 115 { 118 printf ("Getting memory size of the counterpart readonly machine...\n");116 RTPrintf ("Getting memory size of the counterpart readonly machine...\n"); 119 117 ULONG memorySizeRO; 120 118 readonlyMachine->COMGETTER(MemorySize) (&memorySizeRO); 121 printf ("Memory size: %d\n", memorySizeRO);119 RTPrintf ("Memory size: %d\n", memorySizeRO); 122 120 ASSERT_RET (memorySizeRO != memorySizeGot, 0); 123 121 } 124 122 125 printf ("Discarding recent changes...\n");126 CHECK_ RC_RET (machine->DiscardSettings());127 printf ("Are any settings modified after discarding?...\n");128 CHECK_ RC_RET (machine->COMGETTER(SettingsModified) (&modified));129 printf ("%s\n", modified ? "yes" : "no");123 RTPrintf ("Discarding recent changes...\n"); 124 CHECK_ERROR_RET (machine, DiscardSettings(), rc); 125 RTPrintf ("Are any settings modified after discarding?...\n"); 126 CHECK_ERROR_RET (machine, COMGETTER(SettingsModified) (&modified), rc); 127 RTPrintf ("%s\n", modified ? "yes" : "no"); 130 128 ASSERT_RET (!modified, 0); 131 129 132 printf ("Getting memory size once more...\n");133 CHECK_ RC_RET (machine->COMGETTER(MemorySize) (&memorySizeGot));134 printf ("Memory size: %d\n", memorySizeGot);130 RTPrintf ("Getting memory size once more...\n"); 131 CHECK_ERROR_RET (machine, COMGETTER(MemorySize) (&memorySizeGot), rc); 132 RTPrintf ("Memory size: %d\n", memorySizeGot); 135 133 ASSERT_RET (memorySizeGot == memorySize, 0); 136 134 137 135 memorySize = memorySize > 128 ? memorySize / 2 : memorySize * 2; 138 printf("Changing memory size to %d...\n", memorySize);139 CHECK_ RC_RET (machine->COMSETTER(MemorySize) (memorySize));136 RTPrintf("Changing memory size to %d...\n", memorySize); 137 CHECK_ERROR_RET (machine, COMSETTER(MemorySize) (memorySize), rc); 140 138 } 141 139 142 140 Bstr desc; 143 printf ("Getting description...\n");141 RTPrintf ("Getting description...\n"); 144 142 CHECK_ERROR_RET (machine, COMGETTER(Description) (desc.asOutParam()), rc); 145 printf ("Description is: \"%ls\"\n", desc.raw());143 RTPrintf ("Description is: \"%ls\"\n", desc.raw()); 146 144 147 145 desc = L"This is an exemplary description (changed)."; 148 printf ("Setting description to \"%ls\"...\n", desc.raw());146 RTPrintf ("Setting description to \"%ls\"...\n", desc.raw()); 149 147 CHECK_ERROR_RET (machine, COMSETTER(Description) (desc), rc); 150 148 151 printf ("Saving machine settings...\n");152 CHECK_ RC (machine->SaveSettings());149 RTPrintf ("Saving machine settings...\n"); 150 CHECK_ERROR (machine, SaveSettings()); 153 151 if (SUCCEEDED (rc)) 154 152 { 155 printf ("Are any settings modified after saving?...\n");156 CHECK_ RC_RET (machine->COMGETTER(SettingsModified) (&modified));157 printf ("%s\n", modified ? "yes" : "no");153 RTPrintf ("Are any settings modified after saving?...\n"); 154 CHECK_ERROR_RET (machine, COMGETTER(SettingsModified) (&modified), rc); 155 RTPrintf ("%s\n", modified ? "yes" : "no"); 158 156 ASSERT_RET (!modified, 0); 159 157 160 158 if (readonlyMachine) { 161 printf ("Getting memory size of the counterpart readonly machine...\n");159 RTPrintf ("Getting memory size of the counterpart readonly machine...\n"); 162 160 ULONG memorySizeRO; 163 161 readonlyMachine->COMGETTER(MemorySize) (&memorySizeRO); 164 printf ("Memory size: %d\n", memorySizeRO);162 RTPrintf ("Memory size: %d\n", memorySizeRO); 165 163 ASSERT_RET (memorySizeRO == memorySize, 0); 166 164 } … … 169 167 Bstr extraDataKey = L"Blafasel"; 170 168 Bstr extraData; 171 printf ("Getting extra data key {%ls}...\n", extraDataKey.raw());172 CHECK_ RC_RET (machine->GetExtraData (extraDataKey, extraData.asOutParam()));169 RTPrintf ("Getting extra data key {%ls}...\n", extraDataKey.raw()); 170 CHECK_ERROR_RET (machine, GetExtraData (extraDataKey, extraData.asOutParam()), rc); 173 171 if (!extraData.isEmpty()) { 174 printf ("Extra data value: {%ls}\n", extraData.raw());172 RTPrintf ("Extra data value: {%ls}\n", extraData.raw()); 175 173 } else { 176 174 if (extraData.isNull()) 177 printf ("No extra data exists\n");175 RTPrintf ("No extra data exists\n"); 178 176 else 179 printf ("Extra data is empty\n");177 RTPrintf ("Extra data is empty\n"); 180 178 } 181 179 … … 184 182 else 185 183 extraData.setNull(); 186 printf (184 RTPrintf ( 187 185 "Setting extra data key {%ls} to {%ls}...\n", 188 186 extraDataKey.raw(), extraData.raw() 189 187 ); 190 CHECK_ RC (machine->SetExtraData (extraDataKey, extraData));188 CHECK_ERROR (machine, SetExtraData (extraDataKey, extraData)); 191 189 192 190 if (SUCCEEDED (rc)) { 193 printf ("Getting extra data key {%ls} again...\n", extraDataKey.raw());194 CHECK_ RC_RET (machine->GetExtraData (extraDataKey, extraData.asOutParam()));191 RTPrintf ("Getting extra data key {%ls} again...\n", extraDataKey.raw()); 192 CHECK_ERROR_RET (machine, GetExtraData (extraDataKey, extraData.asOutParam()), rc); 195 193 if (!extraData.isEmpty()) { 196 printf ("Extra data value: {%ls}\n", extraData.raw());194 RTPrintf ("Extra data value: {%ls}\n", extraData.raw()); 197 195 } else { 198 196 if (extraData.isNull()) 199 printf ("No extra data exists\n");197 RTPrintf ("No extra data exists\n"); 200 198 else 201 printf ("Extra data is empty\n");199 RTPrintf ("Extra data is empty\n"); 202 200 } 203 201 } … … 222 220 char homeDir [RTPATH_MAX]; 223 221 GetVBoxUserHomeDirectory (homeDir, sizeof (homeDir)); 224 printf ("VirtualBox Home Directory = '%s'\n", homeDir); 225 } 226 227 printf ("Initializing COM...\n"); 228 229 CHECK_RC_RET (com::Initialize()); 222 RTPrintf ("VirtualBox Home Directory = '%s'\n", homeDir); 223 } 224 225 RTPrintf ("Initializing COM...\n"); 226 227 rc = com::Initialize(); 228 if (FAILED(rc)) 229 { 230 RTPrintf("ERROR: failed to initialize COM!\n"); 231 return rc; 232 } 230 233 231 234 do … … 242 245 243 246 Utf8Str nullUtf8Str; 244 printf ("nullUtf8Str='%s'\n", nullUtf8Str.raw());247 RTPrintf ("nullUtf8Str='%s'\n", nullUtf8Str.raw()); 245 248 246 249 Utf8Str simpleUtf8Str = "simpleUtf8Str"; 247 printf ("simpleUtf8Str='%s'\n", simpleUtf8Str.raw());250 RTPrintf ("simpleUtf8Str='%s'\n", simpleUtf8Str.raw()); 248 251 249 252 Utf8Str utf8StrFmt = Utf8StrFmt ("[0=%d]%s[1=%d]", 250 253 0, "utf8StrFmt", 1); 251 printf ("utf8StrFmt='%s'\n", utf8StrFmt.raw()); 252 253 #endif 254 255 printf ("Creating VirtualBox object...\n"); 256 CHECK_RC (virtualBox.createLocalObject (CLSID_VirtualBox)); 254 RTPrintf ("utf8StrFmt='%s'\n", utf8StrFmt.raw()); 255 256 #endif 257 258 RTPrintf ("Creating VirtualBox object...\n"); 259 rc = virtualBox.createLocalObject (CLSID_VirtualBox); 260 if (FAILED(rc)) 261 RTPrintf("ERROR: failed to create the VirtualBox object!\n"); 262 else 263 { 264 rc = session.createInprocObject(CLSID_Session); 265 if (FAILED(rc)) 266 RTPrintf("ERROR: failed to create a session object!\n"); 267 } 268 257 269 if (FAILED (rc)) 258 270 { 259 CHECK_ERROR_NOCALL(); 260 break; 261 } 262 263 printf ("Creating Session object...\n"); 264 CHECK_RC (session.createInprocObject (CLSID_Session)); 265 if (FAILED (rc)) 266 { 267 CHECK_ERROR_NOCALL(); 271 com::ErrorInfo info; 272 if (!info.isFullAvailable() && !info.isBasicAvailable()) 273 { 274 com::GluePrintRCMessage(rc); 275 RTPrintf("Most likely, the VirtualBox COM server is not running or failed to start.\n"); 276 } 277 else 278 com::GluePrintErrorInfo(info); 268 279 break; 269 280 } … … 276 287 //////////////////////////////////////////////////////////////////////////// 277 288 { 278 printf ("Testing VirtualBox::COMGETTER(ProgressOperations)...\n");289 RTPrintf ("Testing VirtualBox::COMGETTER(ProgressOperations)...\n"); 279 290 280 291 for (;;) { … … 284 295 COMGETTER(ProgressOperations)(ComSafeArrayAsOutParam(operations))); 285 296 286 printf ("operations: %d\n", operations.size());297 RTPrintf ("operations: %d\n", operations.size()); 287 298 if (operations.size() == 0) 288 299 break; // No more operations left. … … 292 303 293 304 operations[i]->COMGETTER(Percent)(&percent); 294 printf ("operations[%u]: %ld\n", (unsigned)i, (long)percent);305 RTPrintf ("operations[%u]: %ld\n", (unsigned)i, (long)percent); 295 306 } 296 307 RTThreadSleep (2000); // msec … … 306 317 ComPtr <IVirtualBox> virtualBox2; 307 318 308 printf ("Creating one more VirtualBox object...\n");319 RTPrintf ("Creating one more VirtualBox object...\n"); 309 320 CHECK_RC (virtualBox2.createLocalObject (CLSID_VirtualBox)); 310 321 if (FAILED (rc)) … … 314 325 } 315 326 316 printf ("IVirtualBox(virtualBox)=%p IVirtualBox(virtualBox2)=%p\n",327 RTPrintf ("IVirtualBox(virtualBox)=%p IVirtualBox(virtualBox2)=%p\n", 317 328 (IVirtualBox *) virtualBox, (IVirtualBox *) virtualBox2); 318 329 Assert ((IVirtualBox *) virtualBox == (IVirtualBox *) virtualBox2); … … 322 333 unk2 = virtualBox2; 323 334 324 printf ("IUnknown(virtualBox)=%p IUnknown(virtualBox2)=%p\n",335 RTPrintf ("IUnknown(virtualBox)=%p IUnknown(virtualBox2)=%p\n", 325 336 (IUnknown *) unk, (IUnknown *) unk2); 326 337 Assert ((IUnknown *) unk == (IUnknown *) unk2); … … 329 340 ComPtr <IVirtualBox> vb2 = unk; 330 341 331 printf ("IVirtualBox(IUnknown(virtualBox))=%p IVirtualBox(IUnknown(virtualBox2))=%p\n",342 RTPrintf ("IVirtualBox(IUnknown(virtualBox))=%p IVirtualBox(IUnknown(virtualBox2))=%p\n", 332 343 (IVirtualBox *) vb, (IVirtualBox *) vb2); 333 344 Assert ((IVirtualBox *) vb == (IVirtualBox *) vb2); … … 337 348 ComPtr <IHost> host; 338 349 CHECK_ERROR_BREAK (virtualBox, COMGETTER(Host)(host.asOutParam())); 339 printf (" IHost(host)=%p\n", (IHost *) host);350 RTPrintf (" IHost(host)=%p\n", (IHost *) host); 340 351 ComPtr <IUnknown> unk = host; 341 printf (" IUnknown(host)=%p\n", (IUnknown *) unk);352 RTPrintf (" IUnknown(host)=%p\n", (IUnknown *) unk); 342 353 ComPtr <IHost> host_copy = unk; 343 printf (" IHost(host_copy)=%p\n", (IHost *) host_copy);354 RTPrintf (" IHost(host_copy)=%p\n", (IHost *) host_copy); 344 355 ComPtr <IUnknown> unk_copy = host_copy; 345 printf (" IUnknown(host_copy)=%p\n", (IUnknown *) unk_copy);356 RTPrintf (" IUnknown(host_copy)=%p\n", (IUnknown *) unk_copy); 346 357 Assert ((IUnknown *) unk == (IUnknown *) unk_copy); 347 358 … … 349 360 ComPtr <IUnknown> unk_copy_copy; 350 361 unk_copy.queryInterfaceTo (unk_copy_copy.asOutParam()); 351 printf (" IUnknown(unk_copy)=%p\n", (IUnknown *) unk_copy_copy);362 RTPrintf (" IUnknown(unk_copy)=%p\n", (IUnknown *) unk_copy_copy); 352 363 Assert ((IUnknown *) unk_copy == (IUnknown *) unk_copy_copy); 353 364 /* query IUnknown on IUnknown in the opposite direction */ 354 365 unk_copy_copy.queryInterfaceTo (unk_copy.asOutParam()); 355 printf (" IUnknown(unk_copy_copy)=%p\n", (IUnknown *) unk_copy);366 RTPrintf (" IUnknown(unk_copy_copy)=%p\n", (IUnknown *) unk_copy); 356 367 Assert ((IUnknown *) unk_copy == (IUnknown *) unk_copy_copy); 357 368 … … 363 374 unk_copy_copy.setNull(); 364 375 unk = host; 365 printf (" IUnknown(host)=%p\n", (IUnknown *) unk);376 RTPrintf (" IUnknown(host)=%p\n", (IUnknown *) unk); 366 377 Assert (oldUnk == (IUnknown *) unk); 367 378 } 368 379 369 // printf ("Will be now released (press Enter)...");380 // RTPrintf ("Will be now released (press Enter)..."); 370 381 // getchar(); 371 382 } … … 383 394 Bstr version; 384 395 CHECK_ERROR_BREAK (virtualBox, COMGETTER(Version) (version.asOutParam())); 385 printf ("VirtualBox version = %ls\n", version.raw());396 RTPrintf ("VirtualBox version = %ls\n", version.raw()); 386 397 } 387 398 #endif … … 391 402 //////////////////////////////////////////////////////////////////////////// 392 403 { 393 printf ("Calling IVirtualBox::Machines...\n");404 RTPrintf ("Calling IVirtualBox::Machines...\n"); 394 405 395 406 com::SafeIfaceArray <IMachine> machines; … … 397 408 COMGETTER(Machines) (ComSafeArrayAsOutParam (machines))); 398 409 399 printf ("%u machines registered (machines.isNull()=%d).\n",410 RTPrintf ("%u machines registered (machines.isNull()=%d).\n", 400 411 machines.size(), machines.isNull()); 401 412 … … 404 415 Bstr name; 405 416 CHECK_ERROR_BREAK (machines [i], COMGETTER(Name) (name.asOutParam())); 406 printf ("machines[%u]='%s'\n", i, Utf8Str (name).raw());407 } 408 409 #if 0 410 { 411 printf ("Testing [out] arrays...\n");417 RTPrintf ("machines[%u]='%s'\n", i, Utf8Str (name).raw()); 418 } 419 420 #if 0 421 { 422 RTPrintf ("Testing [out] arrays...\n"); 412 423 com::SafeGUIDArray uuids; 413 424 CHECK_ERROR_BREAK (virtualBox, … … 415 426 416 427 for (size_t i = 0; i < uuids.size(); ++ i) 417 printf ("uuids[%u]=%Vuuid\n", i, &uuids [i]);418 } 419 420 { 421 printf ("Testing [in] arrays...\n");428 RTPrintf ("uuids[%u]=%Vuuid\n", i, &uuids [i]); 429 } 430 431 { 432 RTPrintf ("Testing [in] arrays...\n"); 422 433 com::SafeGUIDArray uuids (5); 423 434 for (size_t i = 0; i < uuids.size(); ++ i) … … 426 437 id.create(); 427 438 uuids [i] = id; 428 printf ("uuids[%u]=%Vuuid\n", i, &uuids [i]);439 RTPrintf ("uuids[%u]=%Vuuid\n", i, &uuids [i]); 429 440 } 430 441 … … 441 452 //////////////////////////////////////////////////////////////////////////// 442 453 443 printf("Getting IHost interface...\n");454 RTPrintf("Getting IHost interface...\n"); 444 455 IHost *host; 445 456 rc = virtualBox->GetHost(&host); … … 458 469 dvdDrive->GetDriveName(&driveName); 459 470 RTUtf16ToUtf8((PCRTUTF16)driveName, &driveNameUtf8); 460 printf("Host DVD drive name: %s\n", driveNameUtf8);471 RTPrintf("Host DVD drive name: %s\n", driveNameUtf8); 461 472 RTStrFree(driveNameUtf8); 462 473 SysFreeString(driveName); … … 468 479 } else 469 480 { 470 printf("Could not get host DVD drive collection\n");481 RTPrintf("Could not get host DVD drive collection\n"); 471 482 } 472 483 … … 483 494 floppyDrive->GetDriveName(&driveName); 484 495 RTUtf16ToUtf8((PCRTUTF16)driveName, &driveNameUtf8); 485 printf("Host floppy drive name: %s\n", driveNameUtf8);496 RTPrintf("Host floppy drive name: %s\n", driveNameUtf8); 486 497 RTStrFree(driveNameUtf8); 487 498 SysFreeString(driveName); … … 493 504 } else 494 505 { 495 printf("Could not get host floppy drive collection\n");506 RTPrintf("Could not get host floppy drive collection\n"); 496 507 } 497 508 host->Release(); 498 509 } else 499 510 { 500 printf("Call failed\n");501 } 502 printf ("\n");511 RTPrintf("Call failed\n"); 512 } 513 RTPrintf ("\n"); 503 514 #endif 504 515 … … 513 524 ComPtr <IHardDisk> hardDisk; 514 525 rc = virtualBox->GetHardDisk(uuid, hardDisk.asOutParam()); 515 printf ("virtualBox->GetHardDisk(null-uuid)=%08X\n", rc);526 RTPrintf ("virtualBox->GetHardDisk(null-uuid)=%08X\n", rc); 516 527 517 528 // { … … 523 534 Bstr version; 524 535 rc = virtualBox->COMGETTER(Version) (version.asOutParam()); 525 printf ("virtualBox->COMGETTER(Version)=%08X\n", rc);536 RTPrintf ("virtualBox->COMGETTER(Version)=%08X\n", rc); 526 537 527 538 { … … 535 546 ComPtr <IMachine> machine; 536 547 rc = session->COMGETTER(Machine)(machine.asOutParam()); 537 printf ("session->COMGETTER(Machine)=%08X\n", rc);548 RTPrintf ("session->COMGETTER(Machine)=%08X\n", rc); 538 549 539 550 // { … … 545 556 SessionState_T state; 546 557 rc = session->COMGETTER(State) (&state); 547 printf ("session->COMGETTER(State)=%08X\n", rc);558 RTPrintf ("session->COMGETTER(State)=%08X\n", rc); 548 559 549 560 { … … 561 572 ComPtr <IHardDisk> hd; 562 573 Bstr src = L"E:\\develop\\innotek\\images\\NewHardDisk.vdi"; 563 printf ("Opening the existing hard disk '%ls'...\n", src.raw());574 RTPrintf ("Opening the existing hard disk '%ls'...\n", src.raw()); 564 575 CHECK_ERROR_BREAK (virtualBox, OpenHardDisk (src, AccessMode_ReadWrite, hd.asOutParam())); 565 printf ("Enter to continue...\n");576 RTPrintf ("Enter to continue...\n"); 566 577 getchar(); 567 printf ("Registering the existing hard disk '%ls'...\n", src.raw());578 RTPrintf ("Registering the existing hard disk '%ls'...\n", src.raw()); 568 579 CHECK_ERROR_BREAK (virtualBox, RegisterHardDisk (hd)); 569 printf ("Enter to continue...\n");580 RTPrintf ("Enter to continue...\n"); 570 581 getchar(); 571 582 } 572 583 while (FALSE); 573 printf ("\n");584 RTPrintf ("\n"); 574 585 #endif 575 586 … … 581 592 ComPtr <IVirtualDiskImage> vdi; 582 593 Bstr src = L"CreatorTest.vdi"; 583 printf ("Unregistering the hard disk '%ls'...\n", src.raw());594 RTPrintf ("Unregistering the hard disk '%ls'...\n", src.raw()); 584 595 CHECK_ERROR_BREAK (virtualBox, FindVirtualDiskImage (src, vdi.asOutParam())); 585 596 ComPtr <IHardDisk> hd = vdi; … … 589 600 } 590 601 while (FALSE); 591 printf ("\n");602 RTPrintf ("\n"); 592 603 #endif 593 604 … … 623 634 } 624 635 while (FALSE); 625 printf ("\n");636 RTPrintf ("\n"); 626 637 #endif 627 638 … … 645 656 }; 646 657 647 printf ("\n");658 RTPrintf ("\n"); 648 659 649 660 for (size_t i = 0; i < RT_ELEMENTS (Names); ++ i) 650 661 { 651 662 Bstr src = Names [i]; 652 printf ("Searching for hard disk '%ls'...\n", src.raw());663 RTPrintf ("Searching for hard disk '%ls'...\n", src.raw()); 653 664 rc = virtualBox->FindHardDisk (src, hd.asOutParam()); 654 665 if (SUCCEEDED (rc)) … … 658 669 CHECK_ERROR_BREAK (hd, COMGETTER(Id) (id.asOutParam())); 659 670 CHECK_ERROR_BREAK (hd, COMGETTER(Location) (location.asOutParam())); 660 printf ("Found, UUID={%Vuuid}, location='%ls'.\n",671 RTPrintf ("Found, UUID={%Vuuid}, location='%ls'.\n", 661 672 id.raw(), location.raw()); 662 673 … … 668 679 ComSafeArrayAsOutParam (values))); 669 680 670 printf ("Properties:\n");681 RTPrintf ("Properties:\n"); 671 682 for (size_t i = 0; i < names.size(); ++ i) 672 printf (" %ls = %ls\n", names [i], values [i]);683 RTPrintf (" %ls = %ls\n", names [i], values [i]); 673 684 674 685 if (names.size() == 0) 675 printf (" <none>\n");686 RTPrintf (" <none>\n"); 676 687 677 688 #if 0 … … 679 690 Bstr value = Utf8StrFmt ("lalala (%llu)", RTTimeMilliTS()); 680 691 681 printf ("Settings property %ls to %ls...\n", name.raw(), value.raw());692 RTPrintf ("Settings property %ls to %ls...\n", name.raw(), value.raw()); 682 693 CHECK_ERROR (hd, SetProperty (name, value)); 683 694 #endif … … 688 699 PRINT_ERROR_INFO (info); 689 700 } 690 printf ("\n");701 RTPrintf ("\n"); 691 702 } 692 703 } 693 704 while (FALSE); 694 printf ("\n");705 RTPrintf ("\n"); 695 706 #endif 696 707 … … 702 713 ComPtr <IMachine> machine; 703 714 Bstr name = argc > 1 ? argv [1] : "dos"; 704 printf ("Getting a machine object named '%ls'...\n", name.raw());715 RTPrintf ("Getting a machine object named '%ls'...\n", name.raw()); 705 716 CHECK_ERROR_BREAK (virtualBox, FindMachine (name, machine.asOutParam())); 706 printf ("Accessing the machine in read-only mode:\n");717 RTPrintf ("Accessing the machine in read-only mode:\n"); 707 718 readAndChangeMachineSettings (machine); 708 719 #if 0 709 720 if (argc != 2) 710 721 { 711 printf ("Error: a string has to be supplied!\n");722 RTPrintf ("Error: a string has to be supplied!\n"); 712 723 } 713 724 else … … 719 730 } 720 731 while (0); 721 printf ("\n");732 RTPrintf ("\n"); 722 733 #endif 723 734 … … 735 746 Bstr name = L"machina"; 736 747 737 printf ("Creating a new machine object (base dir '%ls', name '%ls')...\n",748 RTPrintf ("Creating a new machine object (base dir '%ls', name '%ls')...\n", 738 749 baseDir.raw(), name.raw()); 739 750 CHECK_ERROR_BREAK (virtualBox, CreateMachine (baseDir, name, 740 751 machine.asOutParam())); 741 752 742 printf ("Getting name...\n");753 RTPrintf ("Getting name...\n"); 743 754 CHECK_ERROR_BREAK (machine, COMGETTER(Name) (name.asOutParam())); 744 printf ("Name: {%ls}\n", name.raw());755 RTPrintf ("Name: {%ls}\n", name.raw()); 745 756 746 757 BOOL modified = FALSE; 747 printf ("Are any settings modified?...\n");758 RTPrintf ("Are any settings modified?...\n"); 748 759 CHECK_ERROR_BREAK (machine, COMGETTER(SettingsModified) (&modified)); 749 printf ("%s\n", modified ? "yes" : "no");760 RTPrintf ("%s\n", modified ? "yes" : "no"); 750 761 751 762 ASSERT_BREAK (modified == TRUE); 752 763 753 764 name = L"Kakaya prekrasnaya virtual'naya mashina!"; 754 printf ("Setting new name ({%ls})...\n", name.raw());765 RTPrintf ("Setting new name ({%ls})...\n", name.raw()); 755 766 CHECK_ERROR_BREAK (machine, COMSETTER(Name) (name)); 756 767 757 printf ("Setting memory size to 111...\n");768 RTPrintf ("Setting memory size to 111...\n"); 758 769 CHECK_ERROR_BREAK (machine, COMSETTER(MemorySize) (111)); 759 770 760 771 Bstr desc = L"This is an exemplary description."; 761 printf ("Setting description to \"%ls\"...\n", desc.raw());772 RTPrintf ("Setting description to \"%ls\"...\n", desc.raw()); 762 773 CHECK_ERROR_BREAK (machine, COMSETTER(Description) (desc)); 763 774 … … 766 777 CHECK_ERROR_BREAK (virtualBox, GetGuestOSType (type, guestOSType.asOutParam())); 767 778 768 printf ("Saving new machine settings...\n");779 RTPrintf ("Saving new machine settings...\n"); 769 780 CHECK_ERROR_BREAK (machine, SaveSettings()); 770 781 771 printf ("Accessing the newly created machine:\n");782 RTPrintf ("Accessing the newly created machine:\n"); 772 783 readAndChangeMachineSettings (machine); 773 784 } 774 785 while (FALSE); 775 printf ("\n");786 RTPrintf ("\n"); 776 787 #endif 777 788 … … 796 807 Bstr name; 797 808 CHECK_RC_BREAK (drive->COMGETTER(Name) (name.asOutParam())); 798 printf ("Host DVD drive: name={%ls}\n", name.raw());809 RTPrintf ("Host DVD drive: name={%ls}\n", name.raw()); 799 810 } 800 811 CHECK_RC_BREAK (rc); … … 808 819 Bstr name; 809 820 CHECK_RC_BREAK (drive->COMGETTER(Name) (name.asOutParam())); 810 printf ("Found by name: name={%ls}\n", name.raw());821 RTPrintf ("Found by name: name={%ls}\n", name.raw()); 811 822 } 812 823 } 813 824 } 814 825 while (FALSE); 815 printf ("\n");826 RTPrintf ("\n"); 816 827 #endif 817 828 … … 905 916 COMGETTER(HardDisks)(ComSafeArrayAsOutParam (disks))); 906 917 907 printf ("%u base hard disks registered (disks.isNull()=%d).\n",918 RTPrintf ("%u base hard disks registered (disks.isNull()=%d).\n", 908 919 disks.size(), disks.isNull()); 909 920 … … 919 930 CHECK_ERROR_BREAK (disks [i], COMGETTER(Format) (format.asOutParam())); 920 931 921 printf (" disks[%u]: '%ls'\n"932 RTPrintf (" disks[%u]: '%ls'\n" 922 933 " UUID: {%Vuuid}\n" 923 934 " State: %s\n" … … 937 948 CHECK_ERROR_BREAK (disks [i], 938 949 COMGETTER(LastAccessError)(error.asOutParam())); 939 printf (" Access Error: %ls\n", error.raw());950 RTPrintf (" Access Error: %ls\n", error.raw()); 940 951 } 941 952 942 953 /* get usage */ 943 954 944 printf (" Used by VMs:\n");955 RTPrintf (" Used by VMs:\n"); 945 956 946 957 com::SafeGUIDArray ids; … … 949 960 if (ids.size() == 0) 950 961 { 951 printf (" <not used>\n");962 RTPrintf (" <not used>\n"); 952 963 } 953 964 else … … 955 966 for (size_t j = 0; j < ids.size(); ++ j) 956 967 { 957 printf (" {%Vuuid}\n", &ids [j]);968 RTPrintf (" {%Vuuid}\n", &ids [j]); 958 969 } 959 970 } … … 965 976 COMGETTER(DVDImages) (ComSafeArrayAsOutParam (images))); 966 977 967 printf ("%u DVD images registered (images.isNull()=%d).\n",978 RTPrintf ("%u DVD images registered (images.isNull()=%d).\n", 968 979 images.size(), images.isNull()); 969 980 … … 977 988 CHECK_ERROR_BREAK (images [i], COMGETTER(State) (&state)); 978 989 979 printf (" images[%u]: '%ls'\n"990 RTPrintf (" images[%u]: '%ls'\n" 980 991 " UUID: {%Vuuid}\n" 981 992 " State: %s\n", … … 993 1004 CHECK_ERROR_BREAK (images [i], 994 1005 COMGETTER(LastAccessError)(error.asOutParam())); 995 printf (" Access Error: %ls\n", error.raw());1006 RTPrintf (" Access Error: %ls\n", error.raw()); 996 1007 } 997 1008 998 1009 /* get usage */ 999 1010 1000 printf (" Used by VMs:\n");1011 RTPrintf (" Used by VMs:\n"); 1001 1012 1002 1013 com::SafeGUIDArray ids; … … 1005 1016 if (ids.size() == 0) 1006 1017 { 1007 printf (" <not used>\n");1018 RTPrintf (" <not used>\n"); 1008 1019 } 1009 1020 else … … 1011 1022 for (size_t j = 0; j < ids.size(); ++ j) 1012 1023 { 1013 printf (" {%Vuuid}\n", &ids [j]);1024 RTPrintf (" {%Vuuid}\n", &ids [j]); 1014 1025 } 1015 1026 } … … 1018 1029 } 1019 1030 while (FALSE); 1020 printf ("\n");1031 RTPrintf ("\n"); 1021 1032 #endif 1022 1033 … … 1028 1039 ComPtr <IMachine> machine; 1029 1040 Bstr name = argc > 1 ? argv [1] : "dos"; 1030 printf ("Getting a machine object named '%ls'...\n", name.raw());1041 RTPrintf ("Getting a machine object named '%ls'...\n", name.raw()); 1031 1042 CHECK_ERROR_BREAK (virtualBox, FindMachine (name, machine.asOutParam())); 1032 1043 Guid guid; 1033 1044 CHECK_RC_BREAK (machine->COMGETTER(Id) (guid.asOutParam())); 1034 printf ("Opening a session for this machine...\n");1045 RTPrintf ("Opening a session for this machine...\n"); 1035 1046 CHECK_RC_BREAK (virtualBox->OpenSession (session, guid)); 1036 1047 #if 1 1037 1048 ComPtr <IMachine> sessionMachine; 1038 printf ("Getting sessioned machine object...\n");1049 RTPrintf ("Getting sessioned machine object...\n"); 1039 1050 CHECK_RC_BREAK (session->COMGETTER(Machine) (sessionMachine.asOutParam())); 1040 printf ("Accessing the machine within the session:\n");1051 RTPrintf ("Accessing the machine within the session:\n"); 1041 1052 readAndChangeMachineSettings (sessionMachine, machine); 1042 1053 #if 0 1043 printf ("\n");1044 printf ("Enabling the VRDP server (must succeed even if the VM is saved):\n");1054 RTPrintf ("\n"); 1055 RTPrintf ("Enabling the VRDP server (must succeed even if the VM is saved):\n"); 1045 1056 ComPtr <IVRDPServer> vrdp; 1046 1057 CHECK_ERROR_BREAK (sessionMachine, COMGETTER(VRDPServer) (vrdp.asOutParam())); … … 1053 1064 BOOL enabled = FALSE; 1054 1065 CHECK_ERROR_BREAK (vrdp, COMGETTER(Enabled) (&enabled)); 1055 printf ("VRDP server is %s\n", enabled ? "enabled" : "disabled");1066 RTPrintf ("VRDP server is %s\n", enabled ? "enabled" : "disabled"); 1056 1067 } 1057 1068 #endif … … 1059 1070 #if 0 1060 1071 ComPtr <IConsole> console; 1061 printf ("Getting the console object...\n");1072 RTPrintf ("Getting the console object...\n"); 1062 1073 CHECK_RC_BREAK (session->COMGETTER(Console) (console.asOutParam())); 1063 printf ("Discarding the current machine state...\n");1074 RTPrintf ("Discarding the current machine state...\n"); 1064 1075 ComPtr <IProgress> progress; 1065 1076 CHECK_ERROR_BREAK (console, DiscardCurrentState (progress.asOutParam())); 1066 printf ("Waiting for completion...\n");1077 RTPrintf ("Waiting for completion...\n"); 1067 1078 CHECK_ERROR_BREAK (progress, WaitForCompletion (-1)); 1068 1079 ProgressErrorInfo ei (progress); … … 1074 1085 CHECK_ERROR_BREAK (progress, COMGETTER(Initiator) (initiator.asOutParam())); 1075 1086 1076 printf ("initiator(unk) = %p\n", (IUnknown *) initiator);1077 printf ("console(unk) = %p\n", (IUnknown *) ComPtr <IUnknown> ((IConsole *) console));1078 printf ("console = %p\n", (IConsole *) console);1079 } 1080 #endif 1081 printf("Press enter to close session...");1087 RTPrintf ("initiator(unk) = %p\n", (IUnknown *) initiator); 1088 RTPrintf ("console(unk) = %p\n", (IUnknown *) ComPtr <IUnknown> ((IConsole *) console)); 1089 RTPrintf ("console = %p\n", (IConsole *) console); 1090 } 1091 #endif 1092 RTPrintf("Press enter to close session..."); 1082 1093 getchar(); 1083 1094 session->Close(); 1084 1095 } 1085 1096 while (FALSE); 1086 printf ("\n");1097 RTPrintf ("\n"); 1087 1098 #endif 1088 1099 … … 1094 1105 ComPtr <IMachine> machine; 1095 1106 Bstr name = L"dos"; 1096 printf ("Getting a machine object named '%ls'...\n", name.raw());1107 RTPrintf ("Getting a machine object named '%ls'...\n", name.raw()); 1097 1108 CHECK_RC_BREAK (virtualBox->FindMachine (name, machine.asOutParam())); 1098 1109 Guid guid; 1099 1110 CHECK_RC_BREAK (machine->COMGETTER(Id) (guid.asOutParam())); 1100 printf ("Opening a remote session for this machine...\n");1111 RTPrintf ("Opening a remote session for this machine...\n"); 1101 1112 ComPtr <IProgress> progress; 1102 1113 CHECK_RC_BREAK (virtualBox->OpenRemoteSession (session, guid, Bstr("gui"), 1103 1114 NULL, progress.asOutParam())); 1104 printf ("Waiting for the session to open...\n");1115 RTPrintf ("Waiting for the session to open...\n"); 1105 1116 CHECK_RC_BREAK (progress->WaitForCompletion (-1)); 1106 1117 ComPtr <IMachine> sessionMachine; 1107 printf ("Getting sessioned machine object...\n");1118 RTPrintf ("Getting sessioned machine object...\n"); 1108 1119 CHECK_RC_BREAK (session->COMGETTER(Machine) (sessionMachine.asOutParam())); 1109 1120 ComPtr <IConsole> console; 1110 printf ("Getting console object...\n");1121 RTPrintf ("Getting console object...\n"); 1111 1122 CHECK_RC_BREAK (session->COMGETTER(Console) (console.asOutParam())); 1112 printf ("Press enter to pause the VM execution in the remote session...");1123 RTPrintf ("Press enter to pause the VM execution in the remote session..."); 1113 1124 getchar(); 1114 1125 CHECK_RC (console->Pause()); 1115 printf ("Press enter to close this session...");1126 RTPrintf ("Press enter to close this session..."); 1116 1127 getchar(); 1117 1128 session->Close(); 1118 1129 } 1119 1130 while (FALSE); 1120 printf ("\n");1131 RTPrintf ("\n"); 1121 1132 #endif 1122 1133 … … 1128 1139 ComPtr <IMachine> machine; 1129 1140 Bstr name = "dos"; 1130 printf ("Getting a machine object named '%ls'...\n", name.raw());1141 RTPrintf ("Getting a machine object named '%ls'...\n", name.raw()); 1131 1142 CHECK_RC_BREAK (virtualBox->FindMachine (name, machine.asOutParam())); 1132 1143 Guid guid; 1133 1144 CHECK_RC_BREAK (machine->COMGETTER(Id) (guid.asOutParam())); 1134 printf ("Opening an existing remote session for this machine...\n");1145 RTPrintf ("Opening an existing remote session for this machine...\n"); 1135 1146 CHECK_RC_BREAK (virtualBox->OpenExistingSession (session, guid)); 1136 1147 ComPtr <IMachine> sessionMachine; 1137 printf ("Getting sessioned machine object...\n");1148 RTPrintf ("Getting sessioned machine object...\n"); 1138 1149 CHECK_RC_BREAK (session->COMGETTER(Machine) (sessionMachine.asOutParam())); 1139 1150 … … 1145 1156 #if 0 1146 1157 ComPtr <IConsole> console; 1147 printf ("Getting console object...\n");1158 RTPrintf ("Getting console object...\n"); 1148 1159 CHECK_RC_BREAK (session->COMGETTER(Console) (console.asOutParam())); 1149 printf ("Press enter to pause the VM execution in the remote session...");1160 RTPrintf ("Press enter to pause the VM execution in the remote session..."); 1150 1161 getchar(); 1151 1162 CHECK_RC (console->Pause()); 1152 printf ("Press enter to close this session...");1163 RTPrintf ("Press enter to close this session..."); 1153 1164 getchar(); 1154 1165 #endif … … 1156 1167 } 1157 1168 while (FALSE); 1158 printf ("\n");1169 RTPrintf ("\n"); 1159 1170 #endif 1160 1171 … … 1167 1178 ULONG uMemSize, uMemAvail; 1168 1179 CHECK_ERROR_BREAK (host, COMGETTER(MemorySize) (&uMemSize)); 1169 printf("Total memory (MB): %u\n", uMemSize);1180 RTPrintf("Total memory (MB): %u\n", uMemSize); 1170 1181 CHECK_ERROR_BREAK (host, COMGETTER(MemoryAvailable) (&uMemAvail)); 1171 printf("Free memory (MB): %u\n", uMemAvail);1182 RTPrintf("Free memory (MB): %u\n", uMemAvail); 1172 1183 } while (0); 1173 1184 #endif … … 1187 1198 Bstr interfaceName; 1188 1199 networkInterface->COMGETTER(Name)(interfaceName.asOutParam()); 1189 printf("Found %d network interfaces, testing with %lS...\n", hostNetworkInterfaces.size(), interfaceName.raw());1200 RTPrintf("Found %d network interfaces, testing with %lS...\n", hostNetworkInterfaces.size(), interfaceName.raw()); 1190 1201 Guid interfaceGuid; 1191 1202 networkInterface->COMGETTER(Id)(interfaceGuid.asOutParam()); … … 1197 1208 networkInterface->COMGETTER(Id)(interfaceGuid2.asOutParam()); 1198 1209 if (interfaceGuid2 != interfaceGuid) 1199 printf("Failed to retrieve an interface by name %lS.\n", interfaceName.raw());1210 RTPrintf("Failed to retrieve an interface by name %lS.\n", interfaceName.raw()); 1200 1211 // Find the interface by its guid 1201 1212 networkInterface.setNull(); … … 1205 1216 networkInterface->COMGETTER(Name)(interfaceName2.asOutParam()); 1206 1217 if (interfaceName != interfaceName2) 1207 printf("Failed to retrieve an interface by GUID %lS.\n", Bstr(interfaceGuid.toString()).raw());1218 RTPrintf("Failed to retrieve an interface by GUID %lS.\n", Bstr(interfaceGuid.toString()).raw()); 1208 1219 } 1209 1220 else 1210 1221 { 1211 printf("No network interfaces found!\n");1222 RTPrintf("No network interfaces found!\n"); 1212 1223 } 1213 1224 } while (0); … … 1235 1246 Bstr name = argc > 1 ? argv [1] : "dsl"; 1236 1247 Bstr sessionType = argc > 2 ? argv [2] : "vrdp"; 1237 printf ("Getting a machine object named '%ls'...\n", name.raw());1248 RTPrintf ("Getting a machine object named '%ls'...\n", name.raw()); 1238 1249 CHECK_RC_BREAK (virtualBox->FindMachine (name, machine.asOutParam())); 1239 1250 … … 1241 1252 Guid guid; 1242 1253 CHECK_RC_BREAK (machine->COMGETTER(Id) (guid.asOutParam())); 1243 printf ("Opening a remote session for this machine...\n");1254 RTPrintf ("Opening a remote session for this machine...\n"); 1244 1255 ComPtr <IProgress> progress; 1245 1256 CHECK_RC_BREAK (virtualBox->OpenRemoteSession (session, guid, sessionType, 1246 1257 NULL, progress.asOutParam())); 1247 printf ("Waiting for the session to open...\n");1258 RTPrintf ("Waiting for the session to open...\n"); 1248 1259 CHECK_RC_BREAK (progress->WaitForCompletion (-1)); 1249 1260 ComPtr <IMachine> sessionMachine; 1250 printf ("Getting sessioned machine object...\n");1261 RTPrintf ("Getting sessioned machine object...\n"); 1251 1262 CHECK_RC_BREAK (session->COMGETTER(Machine) (sessionMachine.asOutParam())); 1252 1263 … … 1266 1277 // Get console 1267 1278 ComPtr <IConsole> console; 1268 printf ("Getting console object...\n");1279 RTPrintf ("Getting console object...\n"); 1269 1280 CHECK_RC_BREAK (session->COMGETTER(Console) (console.asOutParam())); 1270 1281 1271 1282 RTThreadSleep(5000); // Sleep for 5 seconds 1272 1283 1273 printf("\nMetrics collected with VM running: --------------------\n");1284 RTPrintf("\nMetrics collected with VM running: --------------------\n"); 1274 1285 queryMetrics(virtualBox, collector, ComSafeArrayAsInParam(objects)); 1275 1286 1276 1287 // Pause 1277 // printf ("Press enter to pause the VM execution in the remote session...");1288 //RTPrintf ("Press enter to pause the VM execution in the remote session..."); 1278 1289 //getchar(); 1279 1290 CHECK_RC (console->Pause()); … … 1281 1292 RTThreadSleep(5000); // Sleep for 5 seconds 1282 1293 1283 printf("\nMetrics collected with VM paused: ---------------------\n");1294 RTPrintf("\nMetrics collected with VM paused: ---------------------\n"); 1284 1295 queryMetrics(virtualBox, collector, ComSafeArrayAsInParam(objects)); 1285 1296 1286 printf("\nDrop collected metrics: ----------------------------------------\n");1297 RTPrintf("\nDrop collected metrics: ----------------------------------------\n"); 1287 1298 CHECK_ERROR_BREAK (collector, 1288 1299 SetupMetrics(ComSafeArrayAsInParam(baseMetrics), … … 1297 1308 machine.queryInterfaceTo(&vmObject[0]); 1298 1309 1299 printf("\nDisable collection of VM metrics: ------------------------------\n");1310 RTPrintf("\nDisable collection of VM metrics: ------------------------------\n"); 1300 1311 CHECK_ERROR_BREAK (collector, 1301 1312 DisableMetrics(ComSafeArrayAsInParam(baseMetrics), … … 1308 1319 queryMetrics(virtualBox, collector, ComSafeArrayAsInParam(objects)); 1309 1320 1310 printf("\nRe-enable collection of all metrics: ---------------------------\n");1321 RTPrintf("\nRe-enable collection of all metrics: ---------------------------\n"); 1311 1322 CHECK_ERROR_BREAK (collector, 1312 1323 EnableMetrics(ComSafeArrayAsInParam(baseMetrics), … … 1320 1331 1321 1332 // Power off 1322 printf ("Press enter to power off VM...");1333 RTPrintf ("Press enter to power off VM..."); 1323 1334 getchar(); 1324 1335 CHECK_RC (console->PowerDown()); 1325 printf ("Press enter to close this session...");1336 RTPrintf ("Press enter to close this session..."); 1326 1337 getchar(); 1327 1338 session->Close(); … … 1356 1367 RTPrintf ("Disks:"); 1357 1368 for (unsigned i = 0; i < retDisks.size(); i++) 1358 printf (" %ls", Bstr (retDisks [i]).raw());1369 RTPrintf (" %ls", Bstr (retDisks [i]).raw()); 1359 1370 RTPrintf ("\n"); 1360 1371 } … … 1382 1393 for (unsigned a = 0; a < retTypes.size(); ++a) 1383 1394 { 1384 printf (" %d %ls %ls %ls\n",1395 RTPrintf (" %d %ls %ls %ls\n", 1385 1396 retTypes [a], 1386 1397 Bstr (retOrigValues [a]).raw(), … … 1424 1435 } 1425 1436 while (FALSE); 1426 printf ("\n");1427 #endif 1428 1429 printf ("Press enter to release Session and VirtualBox instances...");1437 RTPrintf ("\n"); 1438 #endif 1439 1440 RTPrintf ("Press enter to release Session and VirtualBox instances..."); 1430 1441 getchar(); 1431 1442 … … 1435 1446 while (0); 1436 1447 1437 printf("Press enter to shutdown COM...");1448 RTPrintf("Press enter to shutdown COM..."); 1438 1449 getchar(); 1439 1450 1440 1451 com::Shutdown(); 1441 1452 1442 printf ("tstAPI FINISHED.\n");1453 RTPrintf ("tstAPI FINISHED.\n"); 1443 1454 1444 1455 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.