Representing IUnknown In Managed C++

869 views Asked by At

I building Wrapper in C++/CLI for C Static library to be used in .NET application through C#

I have function like this in C

long    My_COM_Interface(   PVOID hDevice,IUnknown **pUnknown);

How to declare IUnknown ** in C++/CLI

for first argument I am using IntPtr but Not able to find out the Replacement for IUknown.

I have another COM Data type GUID in another function this is also an issue for me.

Please Help me find the relacement for data type IUnknown and GUID.

3

There are 3 answers

0
sehe On

I'd refer to the APIs, e.g.

 public static IntPtr GetIUnknownForObject(Object o);

This API can simply be used from C++/CLR and suggests you should use IntPtr^

2
Emir Akaydın On

try using parameter like;

ref object pUnknown

and use it like

MyObject o = pUnknown as MyObject
8
Ben Voigt On

There is no replacement.

C++/CLI understands native types just fine. Include the right header files, and you can use IUnknown* like always.