M
Marc Eaddy
Hi,
I have problem wrapping a callback declared in the
unmanged C++ and call a function that sets the callback from C#.
What I want to do is to first wrap an unmanaged C++ class using managed C++.
Then I access this managed C++ code from my C# code.
So here's the unmanaged C++ header: (I don't have access to the source code.
What I have is the .dll and the header file)
// a callback definition
typedef void (__cdecl * callBackFunc)(unsigned char * imageData);
class __declspec(dllexport) UnmanagedClass {
public:
.......
.......
void setCallBack(callBackFunc callback);
.......
}
Now, I want to somehow wrap this class in managed C++, so that I can pass a
delegate as shown below from C# that will be called whenever this
callBackFunc is called in the unmanaged C++ code.
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void CallBackFunc(IntPtr imageData);
How can I wrap the callback (callBackFunc) as well as the setCallBack(...)
function in the unmanaged C++ so that I can
pass this delegate from C# to the wrapped managed C++ code?
Also, is it possible to directly access the unmanaged C++ class from C#
instead of wrapping the class in managed C++ code first?
Any help would be appreciated.
Thanks
Ohan
I have problem wrapping a callback declared in the
unmanged C++ and call a function that sets the callback from C#.
What I want to do is to first wrap an unmanaged C++ class using managed C++.
Then I access this managed C++ code from my C# code.
So here's the unmanaged C++ header: (I don't have access to the source code.
What I have is the .dll and the header file)
// a callback definition
typedef void (__cdecl * callBackFunc)(unsigned char * imageData);
class __declspec(dllexport) UnmanagedClass {
public:
.......
.......
void setCallBack(callBackFunc callback);
.......
}
Now, I want to somehow wrap this class in managed C++, so that I can pass a
delegate as shown below from C# that will be called whenever this
callBackFunc is called in the unmanaged C++ code.
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void CallBackFunc(IntPtr imageData);
How can I wrap the callback (callBackFunc) as well as the setCallBack(...)
function in the unmanaged C++ so that I can
pass this delegate from C# to the wrapped managed C++ code?
Also, is it possible to directly access the unmanaged C++ class from C#
instead of wrapping the class in managed C++ code first?
Any help would be appreciated.
Thanks
Ohan