// **************** START OF CALLBACK REGISTRATION CODE ***************** // Register the callback function // Declare pointer type of the callback function unsafe Int32 RegisterCallBack() { // Function declaration pointer (includes parameters so C++ knows what to send this function) // Grab the C# pointer to the local function: EPTReadFunction MyEPTReadFunctionPTR = new MyEPTReadFunction(EPTReadFunction); // Grab the actual C++ translation of the pointer of the function: IntPtr FctPtr = Marshal.GetFunctionPointerForDelegate(MyEPTReadFunctionPTR); // Sent the C++ translation if (EPT_AH_RegisterReadCallback(FctPtr) == 0) { String message = "Error registering callback function: " + Marshal.PtrToStringAnsi((IntPtr)EPT_AH_GetLastError()); MessageBox.Show(message); return(0); } // Return success return(1); }
// **************** START OF CALLBACK REGISTRATION CODE ***************** // Register the callback function // Declare pointer type of the callback function unsafe Int32 RegisterCallBack() { // Function declaration pointer (includes parameters so C++ knows what to send this function) // Grab the C# pointer to the local function: EPTReadFunction MyEPTReadFunctionPTR = new MyEPTReadFunction(EPTReadFunction); // Grab the actual C++ translation of the pointer of the function: IntPtr FctPtr = Marshal.GetFunctionPointerForDelegate(MyEPTReadFunctionPTR); // Sent the C++ translation if (EPT_AH_RegisterReadCallback(FctPtr) == 0) { String message = "Error registering callback function: " + Marshal.PtrToStringAnsi((IntPtr)EPT_AH_GetLastError()); MessageBox.Show(message); return 0; } // Return success return 1; }