PastorDwayne
asked on
IUnkown as param
Good-day,
I need to pass IUnkown as a parameter to a function. Here is how it is done in C++:
************************** ****
CComObject<CTestImpl> * m_pImpl;
m_pImpl->AddRef();
ICallBackItf * pCallBk = 0;
m_pImpl->QueryInterface(&p CallBk);
m_spInterface1->Function1( pCallBk);
************************** ****
What is the equivalent in C#?
Thanks for your time
I need to pass IUnkown as a parameter to a function. Here is how it is done in C++:
**************************
CComObject<CTestImpl> * m_pImpl;
m_pImpl->AddRef();
ICallBackItf * pCallBk = 0;
m_pImpl->QueryInterface(&p
m_spInterface1->Function1(
**************************
What is the equivalent in C#?
Thanks for your time
ASKER
Thanks for your response. I followed the link, but wasn't able to find any pertinent info. Here's more details: I am attempting to access a COM object which has two interfaces. I add a reference to my C# for this object; I am able to access one of the interfaces, and it's methods. One of the method parameters is IUnknown of the second interface. Here is what I thought might work:
************************** ********
CTestImpl m_spInterface1 = new CTestImpl ();
ICallBackItf cb = m_spInterface1 as ICallBackItf;
spInterface1.(cb);
************************** ********
I thought I could query spInterface1 for the IUnknown of ICallBackItf, but it doesn’t work.
**************************
CTestImpl m_spInterface1 = new CTestImpl ();
ICallBackItf cb = m_spInterface1 as ICallBackItf;
spInterface1.(cb);
**************************
I thought I could query spInterface1 for the IUnknown of ICallBackItf, but it doesn’t work.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You'll need COM interop.
In .NET you'll need the COM type definitions, and then it's just passing back a pointer and assigning it.
Have a look here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconexposingcomcomponentstonetframework.asp?frame=true
hth
Vasco