API parameter is events Structure

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • myregid@gmail.com

    #1

    API parameter is events Structure

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

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

    ¡¾FT_startMonit oringDevice¡¿
    FT_RETCODE FT_startMonitor ingDevice(
    IN FT_HANDLE ftContext, /* device context */
    IN FT_DEVICE_EVENT S_PT events); /* events handle */

    ¡¾FT_HANDLE¡¿
    typedef void *FT_HANDLE;
    ¡¾FT_DEVICE_EVE NTS_PT¡¿
    typedef struct
    {
    FT_HANDLE fingerTouching;
    FT_HANDLE imageReady;
    FT_HANDLE fingerRemoved;
    FT_HANDLE error;
    FT_HANDLE stop; /* ingnored */
    }
    FT_DEVICE_EVENT S, *FT_DEVICE_EVEN TS_PT;
    ----------------------------------------------------------

    Now I declared the functiong in VB:
    ¡¾FT_startMonit oringDevice¡¿
    Public Declare Function FT_startMonitor ingDevice Lib "DPFPFNS" _
    (ByVal ctx As IntPtr, ByRef events As FT_DEVICE_EVENT S) As
    Integer

    ¡¾FT_HANDLE¡¿
    Dim CONTEX As IntPtr
    ¡¾FT_DEVICE_EVE NTS_PT¡¿
    <StructLayout(L ayoutKind.Seque ntial)_
    Public Structure FT_DEVICE_EVENT S
    Public Event fingerTouching( )
    Public Event imageReady()
    Public Event fingerRemoved()
    Public Event Herror()
    Public Event Hstop() '/* ingnored */
    End Structure
    ----------------------------------------------------------

    Samples:
    ¡¾main¡¿
    sub main()
    ....
    AddHandler evnt.fingerRemo ved, AddressOf t1
    AddHandler evnt.fingerTouc hing, AddressOf t2
    AddHandler evnt.imageReady , AddressOf t3
    AddHandler evnt.Herror, AddressOf t4
    AddHandler evnt.Hstop, AddressOf t5
    ....

    Dim thread1 As New Threading.Threa d(AddressOf
    StartMonitoring Device)
    thread1.Start()
    ....
    end sub

    Private Sub t2()
    Console.WriteLi ne("t2")
    End Sub
    .....
    '¡¾Call API¡¿
    Private Sub StartMonitoring Device()
    Dim rc As Integer
    Try
    rc = FT_startMonitor ingDevice(CONTE X, evnt)
    Catch ex As Exception
    console.writeli ne (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,expe cially the events structure

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

  • Mattias Sjögren

    #2
    Re: API parameter is events Structure

    >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,exp ecially 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

    --
    Mattias Sjögren [C# MVP] mattias @ mvps.org
    http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
    Please reply only to the newsgroup.

    Comment

    Working...