[vbox-dev] MSCOM - ISession CoCreateInstance

Klaus Espenlaub klaus.espenlaub at oracle.com
Thu Jun 21 10:07:18 PDT 2012

On 21.06.2012 16:28, Samuel Rats wrote:
> Hi guys,
> I'm currently working on a custom device manager, and I got a little
> probleme : I'm unable to retreive session object from MSCOM
> This work :
> CoCreateInstance(CLSID_VirtualBox, 0, CLSCTX_LOCAL_SERVER,
> IID_IVirtualBox, (void**)&this->vbox);

Yes, because it's getting a reference for an IVirtualBox instance (which 
actually lives in an out of process server, VBoxSVC).

> This does'nt (error 80040154):
> CoCreateInstance(CLSID_Session, 0, CLSCTX_LOCAL_SERVER, IID_ISession,
> (void**)&this->session)

The session object doesn't exist yet, and it must be created in the 
current process. So it must be CLSCTX_INPROC_SERVER.

> Any advice ?

Yes, look at the SDK sample code for this 
(sdk/bindings/mscom/samples/tstVBoxAPIWin.cpp) - it has the respective 
code sequences in it.


More information about the vbox-dev mailing list