I've been trying to build a wrapper to use with the Authentec SDK for
fingerprint scanners. I am a .Net newbie and cannot get the interop dllimport
definition to work and return the result I expect.
Here is the .h function definition:
/////////////////////////////////////////////////////////////////////////////
//
// Function: ATOpenSensor(TCHAR* pszStrSensorName, int16 iOpenMode)
//
// Purpose: Open a sensor for use by the current service.
// For typical systems with only 1 sensor attched, set param
// "pStrSensorName" to NULL.
//
// Parameters: pszStrSensorName: Pointer to freindly name (NULL for only 1
sensor)
// iOpenMode: Either AT_SENSOR_OPEN_MODE_SHARED or
AT_SENSOR_OPEN_MODE_EXCLUSIVE
//
// Returns:
// AT_OK if the operation was successful.
//
// Other: See error codes in ATInterface.h
//
/////////////////////////////////////////////////////////////////////////////
ATDLL_API AT_RESULT_CODE __stdcall ATOpenSensor(TCHAR* pszStrSensorName,
int16 iOpenMode);
I only have one sensor and I am trying to pass a null to it. Here is how I
defined it:
<DllImport("ATSC63.dll", CallingConvention:=CallingConvention.StdCall, _
CharSet:=CharSet.Ansi, EntryPoint:="ATOpenSensorA", SetLastError:=True)> _
Public Shared Function ATOpenSensor(ByVal pszStrSensorName As IntPtr,
ByVal iAccessMode As Int16) As Integer
End Function
And how I have called it:
atResult = ATOpenSensor(IntPtr.Zero, 2)
I expect a result of zero and I get 125960192
I am using Visual Basic .Net...help!

Signature
Ken Jones
Software Engineer
ADP Claims Soultions Group
Alessandro Angeli [MVP::DigitalMedia] - 03 Jan 2005 04:15 GMT
> ATDLL_API AT_RESULT_CODE __stdcall ATOpenSensor(TCHAR*
> pszStrSensorName, int16 iOpenMode);
[quoted text clipped - 15 lines]
>
> I expect a result of zero and I get 125960192
How are AT_RESULT_CODE, AT_SENSOR_OPEN_MODE_SHARED and
AT_SENSOR_OPEN_MODE_EXCLUSIVE defined? Can that number be an
actual error code as defined in ATInterface.h, maybe
0x07820000 or 0x0782 (=1922)? We do not have this SDK and
the informations you posted are not enough. Can
AT_RESULT_CODE be an Int16 instead of an Integer?
(A note about your subject line: tchar* and TCHAR* are not
the same, C/C++ are case-sensitive.)

Signature
// Alessandro Angeli
// MVP :: Digital Media
// a dot angeli at psynet dot net
Ken Jones - 03 Jan 2005 14:59 GMT
Alessandro,
Thanks for the quick response. I believe that AT_RESULT_CODE is defined as
Int32 and AT_SENSOR_OPEN_MODE_SHARED and AT_SENSOR_MODE_EXCLUSIVE are defined
as Int16. In my calling example I used an Integer literal.
As far as the subject line, I just typed everything lower case. I am aware
of the case sensitivity :)
> > ATDLL_API AT_RESULT_CODE __stdcall ATOpenSensor(TCHAR*
> > pszStrSensorName, int16 iOpenMode);
[quoted text clipped - 25 lines]
> (A note about your subject line: tchar* and TCHAR* are not
> the same, C/C++ are case-sensitive.)
Alessandro Angeli [MVP::DigitalMedia] - 03 Jan 2005 17:06 GMT
> Alessandro,
>
[quoted text clipped - 3 lines]
> are defined as Int16. In my calling example I used an
> Integer literal.
I assume you are expecting 0 as result because that means
OK. However, a non-zero result may means either the
iOpenMode argument is invalid (hence I asked what values the
AT_SENSOR_* constants can assume) or that somethings is
wrong with the SDK (hence I asked if the value or the
right-shifted value is a valid error code). Since you say
you believe AT_RESULT_CODE is a 32-bit type but you do not
seem sure, you should check: notice that the lower 16 bits
of the result are 0 so, if AT_RESULT_CODE is actually a
16-bit type, correcting the function declaration may cure
your problem.

Signature
// Alessandro Angeli
// MVP :: Digital Media
// a dot angeli at psynet dot net
Ken Jones - 03 Jan 2005 17:15 GMT
Alessandro,
I will verify my previous post when I get home later today. Thanks again!
> > Alessandro,
> >
[quoted text clipped - 15 lines]
> 16-bit type, correcting the function declaration may cure
> your problem.
Ken Jones - 04 Jan 2005 00:31 GMT
Alessandro,
Here is the typedef for AT_RESULT_CODE:
typedef int16 AT_RESULT_CODE
and for AT_SENSOR_MODE_SHARED and AT_SENSOR_MODE_EXCLUSIVE:
//Context with which the sensor is opened
#define AT_SENSOR_OPEN_MODE_SHARED 1
#define AT_SENSOR_OPEN_MODE_EXCLUSIVE 2
Let me know if I can provide any more info...
Ken
> Alessandro,
>
[quoted text clipped - 19 lines]
> > 16-bit type, correcting the function declaration may cure
> > your problem.
Ken Jones - 04 Jan 2005 00:39 GMT
Alessandro,
Eureka!!! I got it to work!!!
Here is the definition I used:
<DllImport("ATSC63.dll", CallingConvention:=CallingConvention.StdCall, _
CharSet:=CharSet.Ansi, EntryPoint:="ATOpenSensorA", SetLastError:=True)> _
Public Shared Function ATOpenSensor(ByVal pszStrSensorName As IntPtr,
ByVal iAccessMode As Int16) As Int16
End Function
And the Call:
Const AT_SENSOR_OPEN_MODE_EXCLUSIVE = 2
Dim atResult As Int16
atResult = ATOpenSensor(IntPtr.Zero,
AT_SENSOR_OPEN_MODE_EXCLUSIVE)
Thanks for pointing out the obvious...I think I have been working on this so
long that I could not see the type mismatches!!!
Ken
> Alessandro,
>
[quoted text clipped - 35 lines]
> > > 16-bit type, correcting the function declaration may cure
> > > your problem.
Uwe Bohnhoff - 27 Apr 2005 13:35 GMT
Hello,
i have great problems with other SDK's from the authentec SDK.
Do you have the VB.NET call's for the Fingerprint-Functions ??
GetListOfAllUsers(..) and the enroll-Functions.
I hope, I hear something from you