Click here to Skip to main content
15,868,141 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I have created a COM+ in C#. I have managed to use this COM+ object from another C# project successfully.

Now I would like to access this COM+ object from C++. Does anyone have any ideas on how I should do this? Maybe you could point me to some useful articles with examples.

Thanks in advance.
Posted
Comments
Eugen Podsypalnikov 6-Jul-11 9:54am    
In general case
you could begin at CoCreateInstance(..) function :)
See also: http://www.jj54.com/73850-CoCreateInstance-Fails-On-COM-43-Object-With-Object-Construction-Enabled-And-No-Constructor-String-Present/
Ryan Zahra 6-Jul-11 10:03am    
Thanks for your reply. I know how to use COM object in C++ using the CoCreateInstance function, however I'm still lost as how to use the COM+ object in C++.
Eugen Podsypalnikov 6-Jul-11 10:10am    
Probably I would use some interface(s) of an COM+ object in the same (COM) way... :)
Ryan Zahra 6-Jul-11 10:12am    
Thanks for your reply. Do you have any examples please?
Eugen Podsypalnikov 6-Jul-11 10:23am    
static const CLSID CLSID_MYLAYER = {
0x9912EF9F, 0x0FF0, 0x42c1, { 0xAE, 0x6B, 0x74, 0x0C, 0xC8, 0x3D, 0x6D, 0xA8 } };

static const IID IID_MYLAYER = {
0x03A1EE13, 0x2CB6, 0x4b79, { 0xA4, 0xF6, 0x40, 0x65, 0xBB, 0xBE, 0x9B, 0x2B } };

void CSomeUser::SomeStart(..)
{
// IMPILayer* m_pIMPILayer = NULL; // Interface' pointer

HRESULT hr = CoCreateInstance(CLSID_MYLAYER,
NULL,
CLSCTX_INPROC_SERVER,
IID_MYLAYER,
(void**) &m_pIMPILayer);
if (S_OK == hr && m_pIMPILayer) {
m_pIMPILayer->SomeMethodeCall(..)
...
}
}

 
Share this answer
 
Comments
Ryan Zahra 8-Jul-11 3:10am    
Thanks a lot :)
The point of COM is that you shouldn't need to do anything different, regardless of the language used. So any tuturial on using COM+ from C++ should work fine.
 
Share this answer
 
Comments
fjdiewornncalwe 7-Jul-11 21:36pm    
True, but I remember the first time I had to do this and the first time was excruciating. Mind you that was with dotNet1.1 where the COM interop facilities were a very manual process.
Ryan Zahra 8-Jul-11 3:10am    
Exactly. The first time is always the most difficult until you get the hang of it. Once you do it at least once, it's pretty straight forward.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900