[vbox-dev] again with Machine States using API
Wiem
mkaouer at yahoo.fr
Thu Mar 18 19:55:34 GMT 2010
Hello
I'm newby to VirtualBox API (I've been using VMWare for months and now I'm
joining VirtualBox community)
I want to code a sample program that manage installer virtual machines
(start, stop, save, retore etc)
I started using the sample code given with SDK
My sample program worked and I needed to check the virtual machine state in
order to figure out which operations are granted (PoweredOff : start and
restore, Running : stop, save etc) and it doesn't work for me, I tried
checking machine state using Imachine, Isession, Iconsole and I'm always
recovering rc failure "Error retrieving State" (check my code below)
I would like to know :
1. Which classes should be implemented to be able to check machine state ?
2. Which class / interface should I be using to check machine state ?
Thank you very much
Wiem
//--------------------------------------------------------------------------
-------------------------------------------------
Do
{
printf("Starting VM \n");
/* Start a VM session using the delivered VBox GUI. */
rc = virtualBox->OpenRemoteSession (session, guid, sessiontype, NULL,
&progress);
if (!SUCCEEDED(rc))
{
printf("Could not open remote session. rc = 0x%x\n", rc);
getchar();
break;
}
printf("VM successfully started \n");
getchar();
/* Wait until VM is running. */
printf ("Running VM\n");
rc = progress->WaitForCompletion (-1);
if (!SUCCEEDED(rc))
{
printf("Could not start host VM. rc = 0x%x\n", rc);
getchar();
break;
}
/* Get console object. */
session->get_Console(&console);
/* Bring console window to front. */
machine->ShowConsoleWindow(0);
rc = console->get_State(MS); // MS is a MachineState *
if (SUCCEEDED(rc))
{
printf("Current State: %S\n", GetStateName(MS)); //
GetStateName() : converts enum result to string
}
else
{
printf("Error retrieving State \n");
}
}While(0) ;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.virtualbox.org/pipermail/vbox-dev/attachments/20100318/9be936c5/attachment.html>
More information about the vbox-dev
mailing list