API parameter is events Structure

M

myregid

I am developing an application which used DigitalPersona gold SDK 2.4
under VB.net 2003.

----------------------------------------------------------
api in C++

¡¾FT_startMonitoringDevice¡¿
FT_RETCODE FT_startMonitoringDevice(
IN FT_HANDLE ftContext, /* device context */
IN FT_DEVICE_EVENTS_PT events); /* events handle */

¡¾FT_HANDLE¡¿
typedef void *FT_HANDLE;
¡¾FT_DEVICE_EVENTS_PT¡¿
typedef struct
{
FT_HANDLE fingerTouching;
FT_HANDLE imageReady;
FT_HANDLE fingerRemoved;
FT_HANDLE error;
FT_HANDLE stop; /* ingnored */
}
FT_DEVICE_EVENTS, *FT_DEVICE_EVENTS_PT;
----------------------------------------------------------

Now I declared the functiong in VB:
¡¾FT_startMonitoringDevice¡¿
Public Declare Function FT_startMonitoringDevice Lib "DPFPFNS" _
(ByVal ctx As IntPtr, ByRef events As FT_DEVICE_EVENTS) As
Integer

¡¾FT_HANDLE¡¿
Dim CONTEX As IntPtr
¡¾FT_DEVICE_EVENTS_PT¡¿
<StructLayout(LayoutKind.Sequential)> _
Public Structure FT_DEVICE_EVENTS
Public Event fingerTouching()
Public Event imageReady()
Public Event fingerRemoved()
Public Event Herror()
Public Event Hstop() '/* ingnored */
End Structure
----------------------------------------------------------

Samples:
¡¾main¡¿
sub main()
....
AddHandler evnt.fingerRemoved, AddressOf t1
AddHandler evnt.fingerTouching, AddressOf t2
AddHandler evnt.imageReady, AddressOf t3
AddHandler evnt.Herror, AddressOf t4
AddHandler evnt.Hstop, AddressOf t5
....

Dim thread1 As New Threading.Thread(AddressOf
StartMonitoringDevice)
thread1.Start()
....
end sub

Private Sub t2()
Console.WriteLine("t2")
End Sub
.....
'¡¾Call API¡¿
Private Sub StartMonitoringDevice()
Dim rc As Integer
Try
rc = FT_startMonitoringDevice(CONTEX, evnt)
Catch ex As Exception
console.writeline (ex.Message)
End Try
End Sub

----------------------------------------------------------

¡¾My Questions¡¿
the program can not hold the events so i wonder:
1. what's wrong?
2. How to declare and define the API function and it's
parameters,expecially the events structure

i am a new one, any advise will be appreciated
thanks a lot!
 
M

Mattias Sjögren

1. what's wrong?

Probably the events in the structure. A managed event is probably not
compatible with whatever type of event handle the API is expecting.

2. How to declare and define the API function and it's
parameters,expecially the events structure

First you have to figure out what exactly the FT_HANDLE event handle
type represents and how to match that in VB. Unfortunately I can't
help you here since the docs aren't freely available.


Mattias
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top