Private Sub SetEvents()
WR_mfSetEvent E_EVENT_CODELINE, AddressOf MFS100_OnCodeline
WR_mfSetEvent E_EVENT_DOCUMENTDONE, AddressOf MFS100_OnDocumentDone
WR_mfSetEvent E_EVENT_ERROR, AddressOf MFS100_OnError
WR_mfSetEvent E_EVENT_ALLDONE, AddressOf MFS100_OnAllDone
End Sub
Enum EventEnum
E_EVENT_CODELINE = 0
E_EVENT_RAWIMAGEFRONT
E_EVENT_RAWIMAGEBACK
E_EVENT_RAWMICRBUFFER
E_EVENT_RAWOCRBUFFER
E_EVENT_DOCUMENTDONE
E_EVENT_WARNING
E_EVENT_ERROR
E_EVENT_ALLDONE
End Enum
Как я могу преобразовать этот код в C #?
Обновление 1: у меня проблема со Scan и ScanFeeder. ScanFeeder возвращает код MICR, но я не могу его обработать. Функция сканирования получает сообщение об ошибке чтения-записи.
' mflib routines
' ------------------------------------------------------------------------------------
Declare Function mfInit Lib "mflib.dll.stdcall" (ByVal mode As Long, ByVal fileIni As String) As Long
Declare Function mfClose Lib "mflib.dll.stdcall" (ByVal mode As Long) As Long
Declare Function mfTrace Lib "mflib.dll.stdcall" (ByVal level As Long, ByVal msg As String) As Long
Declare Function mfTraceSet Lib "mflib.dll.stdcall" (ByVal mode As Long, ByVal tracelevel As Long, ByVal maxlen As Long, ByVal fullpathname As String) As Long
Declare Function mfSetParam Lib "mflib.dll.stdcall" (ByVal paramCode As Long, ByVal paramValue As String) As Long
Declare Function mfReset Lib "mflib.dll.stdcall" (ByVal mode As Long) As Long
Declare Function mfGetStatus Lib "mflib.dll.stdcall" (ByVal mode As Long, ByVal ret_statusbuffer As String) As Long
Declare Function mfScan Lib "mflib.dll.stdcall" (ByVal mode As Long, ByVal font As Long, ByVal timeout As Long, ByVal ret_codeline As String, ByRef ret_maxchars As Long) As Long
Declare Function mfEject Lib "mflib.dll.stdcall" (ByVal mode As Long, ByVal pocket As Long, ByVal timeout As Long) As Long
Declare Function mfCalib Lib "mflib.dll.stdcall" (ByVal calibID As Long, ByVal mode As Long, ByRef ret_value As Long) As Long
Declare Function mfScanFeeder Lib "mflib.dll.stdcall" (ByVal mode As Long, ByVal font As Long, ByVal timeout As Long) As Long
Declare Function mfSetEvent Lib "mflib.dll.stdcall" (ByVal eventId As Long, ByVal callback As Long) As Long
Declare Function mfGetErrorDescription Lib "mflib.dll.stdcall" (ByVal errorCode As Long, ByVal ret_errorDescription As String) As Long
Declare Function mfIQALoadConfig Lib "mflib.dll.stdcall" (ByVal configfile As String) As Long
Declare Function mfIQASetParameter Lib "mflib.dll.stdcall" (ByVal paramid As Long, ByVal value As String) As Long
Declare Function mfIQATestFile Lib "mflib.dll.stdcall" (ByVal mask As Long, ByVal front As String, ByVal rear As String) As Long
Declare Function mfIQAGetErrorDescription Lib "mflib.dll.stdcall" (ByVal errorid As Long, ByVal desc As String, ByVal maxlen As Long) As Long
Declare Sub mfSort Lib "mflib.dll.stdcall" (ByVal pocket As Long)
Declare Function mfStop Lib "mflib.dll.stdcall" () As Long
Обновление 2:
Public Function WR_mfSetEvent(eventId As Long, callback As Long) As Long
WriteEvent " event " & GetEventName(eventId)
WR_mfSetEvent = mfSetEvent(eventId, callback)
WriteEventMFSRes WR_mfSetEvent
CScannerForm.lsTest.AddItem ("mfSetEvent : " & WR_mfSetEvent)
End Function
Public Sub WriteEventMFSRes(res As Long)
If res >= 0 Then
If res <> 1 Then WriteEventRes " (" & res & ")"
Else
WriteEventRes " (" & res & "='" & WR_mfGetErrorDescription(res) & "')"
End If
End Sub
Обновление 2: это правильный путь. Я получаю ответный звонок таким образом
MFS100_CodeLineDelegate OnCodeline = new MFS100_CodeLineDelegate(MFS100_OnCodeLine);
Adress = Marshal.GetFunctionPointerForDelegate(OnCodeline);
mfSetEvent(0, Adress.ToInt32());