[Mono-list] How to call a C++ interface class?

J. Perkins jason@379.com
Mon, 12 May 2003 15:59:47 -0400


I have unmanaged DLL that returns a C++ interface, which is a struct 
containing only virtual functions. It's nVidia's CgFX library, in case 
anyone cares, and it looks like so...

struct ICgFXBaseEffect
{
	virtual ULONG AddRef() = 0;
	virtual ULONG Release() = 0;

	virtual HRESULT GetDesc(CgFXEFFECT_DESC* pDesc) = 0;
	virtual HRESULT GetParameterDesc(LPCSTR pParameter, CgFXPARAMETER_DESC* 
pDesc) = 0;
	...
}

I was thinking that I might be able to represent this in C# as a struct 
of IntPtrs, then call Marshal.GetManagedThunkForUnmanagedMethodPtr() to 
wrap the IntPtrs with C# methods. However, I can't find any examples of 
how to use this function, so I'm at a bit of a loss. Can any help me out 
here? Am I on the right path? Has anyone used this call before, and if 
so how does it work? In particular, how do you get an IntPtr to a method 
signature?

Thanks for the help, much appreciated.

Jason
379