[vbox-dev] Regarding about the LaunchVMProcess in c++ code

Klaus Espenlaub klaus.espenlaub at oracle.com
Mon Feb 14 18:14:21 GMT 2011


On 10.02.2011 06:16, John Lee wrote:
> Hello,
>
> I'm trying to employ the usage of the LaunchVMProcess() in c++ for the
> virtual box.
>
> //here is the sample code
> nsCOMPtr<ISession> session;
> {
> nsCOMPtr<nsIComponentManager> manager;
> rc = NS_GetComponentManager (getter_AddRefs (manager));
> if (NS_FAILED(rc))
> {
> printf("Error: could not get component manager! rc=%08X\n", rc);
> return;
> }
> rc = manager->CreateInstanceByContractID (NS_SESSION_CONTRACTID,
> nsnull,
> NS_GET_IID(ISession),
>
> getter_AddRefs(session));
> if (NS_FAILED(rc))
> {
> printf("Error, could not instantiate session object! rc=0x%x\n", rc);
> return;
> }
>
> rc = machine->LockMachine(session, LockType_Write);
> if (NS_FAILED(rc))
> {
> printf("Error, could not lock the machine for the session! rc=0x%x\n", rc);
> return;
> }
> rc = session->GetMachine(getter_AddRefs(machine));
> if (NS_FAILED(rc))
> {
> printf("Error, could not get machine session! rc=0x%x\n", rc);
> return;
> }
>
> rc=machine->LaunchVMProcess(session,sessionType,env,&progress);
>
> }
> nsCOMPtr<IMachine> machine;
>
> The problem formulates at the LaunchVMProcess();
>
> Somehow the VM does not instantiate.

Sure, your code makes no sense whatsoever. You declared the machine 
variable long after you're using it.

> So another method that I have tried to use was declare the machine as
> "IMachine machine;"
>
> Somehow with this methodology, I got the error message that it cannot
> declare variable 'machine' to be a abstract type 'IMachine.'

IMachine is an abtract interface, and it only makes sense to use 
pointers to it...

Klaus


> I'm not sure how to fix this problem. Is there a way to fix the problem?
>
> For further information, I have used the VirtualBox 4.0 SDK and the
> sample code tstVBoxAPILinux.cpp.
>
> Thank you in advance.
>
> Sincerely,
> Suk Kyu Lee
>
>
> _______________________________________________
> vbox-dev mailing list
> vbox-dev at virtualbox.org
> http://vbox.innotek.de/mailman/listinfo/vbox-dev




More information about the vbox-dev mailing list