Hi,
I'm writing an application that has a native c++ layer, and a CLi/C++
layer above it. Above the CLi layer will be C# but that's not
relavent to this post. My question has to do with communicating
between the native layer to the CLi layer. Typically how I do this
is
this ...
**CLi/C++ Layer**
*************** ***************
--MTest.h
namespace Test
{
private delegate void TestDelegate(In t32);
public ref class Test
{
private:
GCHandle testHandle_;
TestDelegate^ testDelegate_;
UnmanagedTest* uTest_;
void init();
void registerNativeC allback();
void TestCallback(In t32);
public:
Test();
}
}
*************** ***************
--MTest.cpp
#include "Test.h"
using namespace Test;
Test::Test()
{
init();
registerNativeC allback();
}
void Test::init()
{
uTest_ = new UnmanagedTest() ;
testDelegate_ = gcnew TestDelegate( this, &Test::TestCall back );
testHandle_ = GCHandle::Alloc ( testDelegate_, GCHandle::Norma l );
}
void Test::registerN ativeCallback()
{
IntPtr ip =
Marshall::GetFu nctionPointerFo rDelegate( testDelegate_ );
uTest_->RegisterCallba ck( static_cast< void(__stdcall *)(int)
>( ip.ToPointer() ) );}
void Test::TestCallb ack(Int32 pointlessParam)
{
}
*************** ***************
The unmanged class UnmanagedTest is just a native class that has a
function pointer variable that is set by the call to RegisterCallbac k.
My question is this, I need to do the exact same thing that I'm doing
here, but with an interface.
Is this possible? And if it is, can you please either show me how or
point me in the right direction?
Thank you in advance,
Matthew