Hi Thanks for the help, but when I tried to compile the cpp program I got the following error:<br><br>E:\vbox\mscom\samples>g++ -Wall -I e:\vbox\mscom\include helloworld.cpp -o helloworld.exe<br>In file included from helloworld.cpp:1:<br>
e:\vbox\mscom\include/VirtualBox.h:19: warning: ignoring #pragma warning<br>helloworld.cpp: In function 'int main(int, char**)':<br>helloworld.cpp:26: warning: format '%x' expects type 'unsigned int', but argument 2 has type 'HRESULT'<br>
C:\Users\AKANTH~1.ADO\AppData\Local\Temp\ccYXyN0g.o:helloworld.cpp:(.text+0x1e): <span style="background-color: rgb(255, 0, 0);">undefined reference to `_imp__CoInitialize@4'</span><br>C:\Users\AKANTH~1.ADO\AppData\Local\Temp\ccYXyN0g.o:helloworld.cpp:(.text+0x32): <span style="background-color: rgb(51, 102, 255);">undefined reference to `IID_IVirtualBox'</span><br>
C:\Users\AKANTH~1.ADO\AppData\Local\Temp\ccYXyN0g.o:helloworld.cpp:(.text+0x49): <span style="background-color: rgb(51, 102, 255);">undefined reference to `CLSID_VirtualBox'</span><br>C:\Users\AKANTH~1.ADO\AppData\Local\Temp\ccYXyN0g.o:helloworld.cpp:(.text+0x4e): <span style="background-color: rgb(51, 102, 255);">undefined reference to `_imp__CoCreateInstance@20'</span><br>
C:\Users\AKANTH~1.ADO\AppData\Local\Temp\ccYXyN0g.o:helloworld.cpp:(.text+0x74): <span style="background-color: rgb(255, 0, 0);">undefined reference to `_imp__CoUninitialize@0'</span><br>collect2: ld returned 1 exit status<span style="background-color: rgb(255, 0, 0);"></span><br>
<br>It seems that the colored red are related to COM/RPC. And colored blue are realted to VBOX<br><br>For ref: the following is the cpp I'm using<br>-----------------------------------------------------------------------------------------------------------------------------------------<br>
#include "VirtualBox.h"<br>#include <stdio.h><br><br>int main(int argc, char *argv[])<br>{<br>     HRESULT rc;<br>      IVirtualBox *virtualBox;<br><br>      do<br>         {<br>             /* Initialize the COM subsystem. */<br>
             CoInitialize(NULL);<br>     <br>            /* Instantiate the VirtualBox root object. */<br>             rc = CoCreateInstance(CLSID_VirtualBox,       /* the VirtualBox base object */<br>                                  NULL,                   /* no aggregation */<br>
                                   CLSCTX_LOCAL_SERVER,    /* the object lives in a server process on this machine */<br>                                   IID_IVirtualBox,        /* IID of the interface */<br>                                   (void**)&virtualBox);<br>
     <br>             if (!SUCCEEDED(rc))<br>             {<br>                 printf("Error creating VirtualBox instance! rc = 0x%x\n", rc);<br>                 break;<br>             }<br>     <br>           <br>
         } while (0);<br>     <br>         CoUninitialize();<br>         return 0;<br>    printf("Hello, world\n");<br>    <br>    return 0;<br>}<br>-------------------------------------------------------------------------------------------------------------------------------------------------<br>
<br>Thanks<br>Arun  <br><br><div class="gmail_quote">On Thu, Jul 14, 2011 at 10:34 PM, Klaus Espenlaub <span dir="ltr"><<a href="mailto:klaus.espenlaub@oracle.com" target="_blank">klaus.espenlaub@oracle.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>On 14.07.2011 13:07, aru wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi,<br>
<br>
Some one please send me a mscom example to start VM or access VM.<br>
</blockquote>
<br>
</div><a href="http://www.virtualbox.org/browser/trunk/src/VBox/Main/testcase/tstVBoxAPIWin.cpp" target="_blank">http://www.virtualbox.org/<u></u>browser/trunk/src/VBox/Main/<u></u>testcase/tstVBoxAPIWin.cpp</a><br>
<br>
Usually it's worth having a peek at the VirtualBox sources - if everything else fails there's VBoxManage, which uses pretty much all interfaces and methods.<br>
<br>
There are only very few places in VirtualBox where it's an option to take shortcuts, so generally all the VirtualBox code goes through the API as well.<br>
<br>
Klaus<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Thanks<br>
Arun<br>
</blockquote>
<br>
______________________________<u></u>_________________<br>
vbox-dev mailing list<br>
<a href="mailto:vbox-dev@virtualbox.org" target="_blank">vbox-dev@virtualbox.org</a><br>
<a href="http://vbox.innotek.de/mailman/listinfo/vbox-dev" target="_blank">http://vbox.innotek.de/<u></u>mailman/listinfo/vbox-dev</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>-----<br>Fight back spam! Download the Blue Frog.<br><a href="http://www.bluesecurity.com/register/s?user=b3Blbl9zb3VyY2VyMzIwMw%3D%3D" target="_blank">http://www.bluesecurity.com/register/s?user=b3Blbl9zb3VyY2VyMzIwMw%3D%3D</a><br>