I can get and launch machines from my app.
is it possible to access the session of a IMachine after the application is restarts?
how to get the session from a machine
-
- Site Moderator
- Posts: 5229
- Joined: 13. Jan 2012, 11:14
- Primary OS: Debian other
- VBox Version: OSE Debian
- Guest OSses: Debian, Win 2k8, Win 7
- Contact:
Re: how to get the session from a machine
Yes, exactly the same way you got a session the first time
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
Manage your VirtualBox infrastructure the free way!
-
- Posts: 3
- Joined: 29. Apr 2016, 22:26
Re: how to get the session from a machine
Ok,
so to get a session I do GetDefaultInterface();
I then use the returned session to launch a vm
BSTR GuiName = SysAllocString(L"gui");
BSTR Environment = SysAllocString(L"");
HRESULT Ret = Machine->LaunchVMProcess( Session, GuiName, Environment, &ProgressObj );
then I restart my app.
after this find the VM
BSTR MachineName = SysAllocString( WideString( NameIn ).c_bstr() );
Virtualbox_tlb::IMachine *Machine = VBox->FindMachine( MachineName );
but if I get a session again GetDefaultInterface() i'm not able to do anything with the VM. i get a message saying the session is not locked.
I tried locking the machine with the session but that didn't work.
What am I doing wrong
Thanks in advance
so to get a session I do GetDefaultInterface();
I then use the returned session to launch a vm
BSTR GuiName = SysAllocString(L"gui");
BSTR Environment = SysAllocString(L"");
HRESULT Ret = Machine->LaunchVMProcess( Session, GuiName, Environment, &ProgressObj );
then I restart my app.
after this find the VM
BSTR MachineName = SysAllocString( WideString( NameIn ).c_bstr() );
Virtualbox_tlb::IMachine *Machine = VBox->FindMachine( MachineName );
but if I get a session again GetDefaultInterface() i'm not able to do anything with the VM. i get a message saying the session is not locked.
I tried locking the machine with the session but that didn't work.
What am I doing wrong
Thanks in advance
-
- Site Moderator
- Posts: 5229
- Joined: 13. Jan 2012, 11:14
- Primary OS: Debian other
- VBox Version: OSE Debian
- Guest OSses: Debian, Win 2k8, Win 7
- Contact:
Re: how to get the session from a machine
Have a look at this Java code sample https://gist.github.com/maxidor/e222a7ca0a19ebcb75f2
You'll see how we get a session for machines, how we edit settings for locked machines (using Isession::getMachine) and finally how we unlock the session (very important)
You'll see how we get a session for machines, how we edit settings for locked machines (using Isession::getMachine) and finally how we unlock the session (very important)
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
Manage your VirtualBox infrastructure the free way!
-
- Posts: 3
- Joined: 29. Apr 2016, 22:26
Re: how to get the session from a machine
Thanks for you help I see where you went wrong.