D
DaTurk
Sorry, some how I clicked post before I finished.
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(Int32);
public ref class Test
{
private:
GCHandle testHandle_;
TestDelegate^ testDelegate_;
UnmanagedTest* uTest_;
void init();
void registerNativeCallback();
void TestCallback(Int32);
public:
Test();
}
}
******************************
--> MTest.cpp
#include "Test.h"
using namespace Test;
Test::Test()
{
init();
registerNativeCallback();
}
void Test::init()
{
uTest_ = new UnmanagedTest();
testDelegate_ = gcnew TestDelegate( this, &Test::TestCallback );
testHandle_ = GCHandle::Alloc( testDelegate_, GCHandle::Normal );
}
void Test::registerNativeCallback()
{
IntPtr ip =
Marshall::GetFunctionPointerForDelegate( testDelegate_ );
uTest_->RegisterCallback( static_cast< void(__stdcall *)(int)
void Test::TestCallback(Int32 pointlessParam)
{
}
******************************
The unmanged class UnmanagedTest is just a native class that has a
function pointer variable that is set by the call to RegisterCallback.
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
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(Int32);
public ref class Test
{
private:
GCHandle testHandle_;
TestDelegate^ testDelegate_;
UnmanagedTest* uTest_;
void init();
void registerNativeCallback();
void TestCallback(Int32);
public:
Test();
}
}
******************************
--> MTest.cpp
#include "Test.h"
using namespace Test;
Test::Test()
{
init();
registerNativeCallback();
}
void Test::init()
{
uTest_ = new UnmanagedTest();
testDelegate_ = gcnew TestDelegate( this, &Test::TestCallback );
testHandle_ = GCHandle::Alloc( testDelegate_, GCHandle::Normal );
}
void Test::registerNativeCallback()
{
IntPtr ip =
Marshall::GetFunctionPointerForDelegate( testDelegate_ );
uTest_->RegisterCallback( static_cast< void(__stdcall *)(int)
}( ip.ToPointer() ) );
void Test::TestCallback(Int32 pointlessParam)
{
}
******************************
The unmanged class UnmanagedTest is just a native class that has a
function pointer variable that is set by the call to RegisterCallback.
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