Hi.
I wanna call callback function of C# project in C++ dll. Function in C++ DLL is like this.
extern "C" __declspec(dllexport) DWORD __stdcall SD_KM_Recognize(
SD_KM_OCR_RESULT* lpResults,
DWORD dwLength,
int ( *CheckInterupt)(int nCommand) = NULL,
void ( *TotalProgressChangeCallBack)(int nLower, int nUpper, int nPos, int nStep, int nStepIncrement, LPCSTR lpszTitle) = NULL
);
In C# project, I've load C++ DLL like this.
delegate void CallbackProgressChange(Int32 nLower, Int32 nUpper, Int32 nPos, Int32 nStep, Int32 nStepIncrement, String szBuffer);
[DllImport("JSOCRBridge.dll", EntryPoint = "SD_KM_Recognize", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
static extern UInt32 SD_KM_Recognize(SD_KM_OCR_RESULT[] result, UInt32 nResultLen, IntPtr nStatus, CallbackProgressChange callback);
Whenever I call SD_KM_Recognize function in C# project, error occurred.
CallbackProgressChange recogcallback = new CallbackProgressChange(ProgressChangeCallBack);
SD_KM_Recognize(ret, 10240, IntPtr.Zero, recogcallback);
Error is "Memory write protection error!".
Reason is that TotalProgressChangeCallBack function write memories into lpszTitle parameter.
How can I fix it?