<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;"><DIV>you need a mutable IMachine instance, refer to following code:</DIV>
<DIV> </DIV><FONT color=#008000 size=2><FONT color=#008000 size=2>
<DIV>// delete a vbox vm given the vm name</DIV></FONT></FONT><FONT size=2>
<DIV>HRESULT DeleteVBoxVM(IN PWSTR vmname)</DIV>
<DIV>{</DIV>
<DIV>HRESULT rc;</DIV>
<DIV></DIV>
<DIV>rc = CreateVBoxCOM();</DIV>
<DIV></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>if</FONT></FONT><FONT size=2> (rc)</DIV>
<DIV></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>return</FONT></FONT><FONT size=2> rc;</DIV>
<DIV>IMachine *machine = NULL;</DIV>
<DIV>ISession *session = g_pSession;</DIV>
<DIV>IMachine *pMutableMachine = NULL;</DIV>
<DIV>rc = g_pVBox->FindMachine(BStr(vmname), &machine);</DIV>
<DIV></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>if</FONT></FONT><FONT size=2> (SUCCEEDED(rc)) </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>do</FONT></FONT><FONT size=2> { </DIV>
<DIV>BSTR uuid;</DIV>
<DIV>machine->get_Id(&uuid); </DIV>
<DIV></DIV>
<DIV>rc = g_pVBox->OpenSession(session, uuid);</DIV>
<DIV>CHECK_ERROR_BREAK(rc);</DIV>
<DIV>rc = session->get_Machine(&pMutableMachine);</DIV>
<DIV>CHECK_ERROR_BREAK(rc);</DIV>
<DIV>rc = pMutableMachine->DetachHardDisk(BStr(L</FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>"IDE"</FONT></FONT><FONT size=2>), 0, 0);</DIV>
<DIV></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>if</FONT></FONT><FONT size=2> (SUCCEEDED(rc)) {</DIV>
<DIV></FONT><FONT color=#008000 size=2><FONT color=#008000 size=2>/* commit changes */</DIV></FONT></FONT><FONT size=2>
<DIV>rc = pMutableMachine->SaveSettings();</DIV>
<DIV>}</DIV>
<DIV>pMutableMachine->Release();</DIV>
<DIV>session->Close();</DIV>
<DIV>CHECK_ERROR_BREAK(rc);</DIV>
<DIV>IMachine *machine1 = NULL;</DIV>
<DIV>rc = g_pVBox->UnregisterMachine(uuid, &machine1); </DIV>
<DIV></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>if</FONT></FONT><FONT size=2> (SUCCEEDED(rc)) {</DIV>
<DIV>machine1->DeleteSettings();</DIV>
<DIV>printf(</FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>"Virtual machine '%ls' has been successfully deleted.\n"</FONT></FONT><FONT size=2>, vmname);</DIV>
<DIV>machine1->Release();</DIV>
<DIV>}</DIV>
<DIV>} </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>while</FONT></FONT><FONT size=2> (0);</DIV>
<DIV></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>if</FONT></FONT><FONT size=2> (machine)</DIV>
<DIV>machine->Release();</DIV>
<DIV>CHECK_ERROR(rc);</DIV>
<DIV>ReleaseVBoxCOM();</DIV>
<DIV></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>return</FONT></FONT><FONT size=2> rc;</DIV>
<DIV>}</DIV>
<DIV></FONT><BR><BR>--- On <B>Mon, 8/10/09, Frédéric SOSSON <I><fsosson@gmail.com></I></B> wrote:<BR></DIV>
<BLOCKQUOTE style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: rgb(16,16,255) 2px solid"><BR>From: Frédéric SOSSON <fsosson@gmail.com><BR>Subject: Re: [vbox-dev] createHardDisk and createBaseStorage<BR>To: vbox-dev@virtualbox.org<BR>Date: Monday, August 10, 2009, 8:11 AM<BR><BR>
<DIV class=plainMail>after using addStorageController, I got this message: The machine is<BR>not mutable (state is 1)<BR><BR>what does it mean?<BR><BR>2009/8/10 Frédéric SOSSON <<A href="http://us.mc343.mail.yahoo.com/mc/compose?to=fsosson@gmail.com" ymailto="mailto:fsosson@gmail.com">fsosson@gmail.com</A>>:<BR>> OK, thanx for the piece of code provided by Nikolay<BR>><BR>> 2009/8/10 Klaus Espenlaub <<A href="http://us.mc343.mail.yahoo.com/mc/compose?to=Klaus.Espenlaub@sun.com" ymailto="mailto:Klaus.Espenlaub@sun.com">Klaus.Espenlaub@sun.com</A>>:<BR>>> Frédéric SOSSON wrote:<BR>>>><BR>>>> do you mean vboxshell ?<BR>>><BR>>> no, I usually don't mean vboxshell if I type VBoxManage ;)<BR>>><BR>>> I know that many python programmers are highly allergic to C++ code, but<BR>>> with VirtualBox it's just a fact that the vast majority of code which uses<BR>>> the API is C++. And
 it should give you at least a hint what the usual<BR>>> sequence of API calls is.<BR>>><BR>>> Nikolay provided python code which does the job, but the same information<BR>>> could be easily distilled out of VBoxManageDisk.cpp in the VirtualBox<BR>>> sources. Or by looking at the API documentation.<BR>>><BR>>> Klaus<BR>>><BR>>>><BR>>>> 2009/8/10 Klaus Espenlaub <<A href="http://us.mc343.mail.yahoo.com/mc/compose?to=Klaus.Espenlaub@sun.com" ymailto="mailto:Klaus.Espenlaub@sun.com">Klaus.Espenlaub@sun.com</A>>:<BR>>>>><BR>>>>> Frédéric SOSSON wrote:<BR>>>>>><BR>>>>>> Hello,<BR>>>>>><BR>>>>>> I try to create hard disk and to use createBaseStorage...<BR>>>>>><BR>>>>>> Do you have a small sample ?<BR>>>>><BR>>>>> The usual "sample" is VBoxManage. The
 total tool is relatively big, but<BR>>>>> each<BR>>>>> subcommand is usually pretty straightforward.<BR>>>>><BR>>>>> Klaus<BR>>>>><BR>>>>><BR>>>><BR>>>><BR>>>><BR>>><BR>>><BR>>> --<BR>>> Dr. Klaus Espenlaub<BR>>> Sun Microsystems GmbH<BR>>> Werkstrasse 24<BR>>> 71384 Weinstadt<BR>>> Germany<BR>>><BR>>> =====================================================================<BR>>> Sitz der Gesellschaft:<BR>>> Sun Microsystems GmbH, Sonnenallee 1, D-85551 Kirchheim-Heimstetten<BR>>> Amtsgericht Muenchen: HRB 161028<BR>>> Geschaeftsfuehrer: Thomas Schroeder, Wolfgang Engels, Wolf Frenkel<BR>>> Vorsitzender des Aufsichtsrates: Martin Haering<BR>>> =====================================================================<BR>>><BR>><BR>><BR>><BR>>
 --<BR>> Frédéric SOSSON<BR>> Tél.: 0032 496 29 29 88<BR>><BR><BR><BR><BR>-- <BR>Frédéric SOSSON<BR>Tél.: 0032 496 29 29 88<BR><BR>_______________________________________________<BR>vbox-dev mailing list<BR><A href="http://us.mc343.mail.yahoo.com/mc/compose?to=vbox-dev@virtualbox.org" ymailto="mailto:vbox-dev@virtualbox.org">vbox-dev@virtualbox.org</A><BR><A href="http://vbox.innotek.de/mailman/listinfo/vbox-dev" target=_blank>http://vbox.innotek.de/mailman/listinfo/vbox-dev</A><BR></DIV></BLOCKQUOTE></td></tr></table>