API to delete VM

Discussions related to using VirtualBox on Windows hosts.
Post Reply
new_vbuser
Posts: 1
Joined: 15. Oct 2008, 07:19

API to delete VM

Post by new_vbuser »

Hi,

Can someone please tell me what is the API to delete the virtual machine ? I am using Axis WS.

Thanks,
new_vbuser
TerryE
Volunteer
Posts: 3572
Joined: 28. May 2008, 08:40
Primary OS: Ubuntu other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Ubuntu 10.04 & 11.10, both Svr&Wstn, Debian, CentOS
Contact:

Post by TerryE »

Welcome to our forum. You might want to take this opportunity to browse the Forum Posting Guide. This contains some useful tips on how to search for VBox knowledge and how to frame Qs. And with your username, I assume that you won't be posting here long otherwise you would become an old new user :lol:

I find that the easiest way to work out what API calls to use is to look at the VBox code since this uses the API itself. You can download the OSE source from the download page, and the best routine to look at is src/VBox/Frontends/VBoxManage/VBoxManage.cpp. Alternatively you can also use the source browser. The routine that you want is handleUnregisterVM which is here in the online browser. This gives the following pseudo code for this delete (you would need to add error handling etc:

Code: Select all

IVirtualBox virtualBox
ISession session
IMachine machine

virtualBox.createLocalObject (CLSID_VirtualBox)
session.createInprocObject (CLSID_Session)
if exists guid 
  virtualBox.GetMachine(guid, machine)
else
  virtualBox.FindMachine(strName, machine)
  guid=machine.uuid
virtualBox.UnregisterMachine(guid, machine)
machine.DeleteSettings()
Given the lack of examples, this is really the best way to work out the API sequences. Hope this helps.
Read the Forum Posting Guide
Google your Q site:VirtualBox.org or search for the answer before posting.
Post Reply