Use of a DLL from a fingerprint reader. DLLImport problems..



Hi everyone!
i'm new at this forum as well as programming in .net
I have to develop a module that can use and configure a fingerprint
detector; its documentation is written in C, as you will see below.
This is the function declaration that appears at the documentation
extern int WINAPI Wis_Diagnose (unsigned char *pwd, SYSTEMDATA
CurSystemData);
This function is for the device test. Ex, PC test if the device is ready.
It returns 0 if the device test is OK; -1 if the device test is NG

Below i write down the two structures that this function uses, as described
in the manual:
typedef struct _SYSTEMDATA
{
unsigned char Version; //DSP version
unsigned char IP[4]; //IP address
unsigned char NetMask[4]; //netmask
unsigned char Gateway[4]; //gateway
unsigned char BaudRate; //baudrate for external
unsigned char DeviceID[3]; //device ID
unsigned short UserNo; //user number
unsigned long LogNo; //log number
unsigned char AuthenMode; //1: 1-1 2: 1:1/1:N(<50 user
unsigned char UartMode; //1:232, 2:485
unsigned char VoiceEN; //1:enable
unsigned char ServerIP[3][4]; //server IP sets
unsigned char IDLength; //ID length for display
unsigned char Reserved[20];




DOORDATA DoorData; //door setting

unsigned char DeviceName[16]; //device name
unsigned char HasDevice; //this parameter should be 3
unsigned char ProtocolPswd; //protocol password
unsigned char Reserved1[7];
}SYSTEMDATA; //112 Bytes

//door data structure
typedef struct _DOORDATA
{
unsigned short DoorOpenSec;
unsigned short DoorOverSec;
unsigned short AlarmTime;
unsigned char AlarmEnable; //0: Disable
unsigned char Reserved[9];
}DOORDATA; //16 bytes


And i have used DLLImport as follows:
<DllImport("C:\WisClient.dll", EntryPoint:="Wis_Diagnose",
SetLastError:=True, _
CharSet:=CharSet.Unicode, ExactSpelling:=True, _
CallingConvention:=CallingConvention.StdCall)> _
Public Shared Function Diagnostico( _
ByVal pwd As String, _
ByRef systemdata As SystemData) _
As Integer
End Function

However, the application doesn't work... One of the error message that shows
is:
PInvokeStackImbalance was detected
Message: A call to PInvoke function ....' has unbalanced the stack. This is
likely because the managed PInvoke signature does not match the unmanaged
target signature. Check that the calling convention and parameters of the
PInvoke signature match the target unmanaged signature.
Some other times (for example, when i change byref instead of byval), the
above error message doesn't show but it appears an unhandled win32
exception...

I have all the documentation in a PDF, and i would really appreciate someone
give me a hand on all of this.
Thanks very much in advance!


--
Emilio Javier Leyes
Técnico Universitario en Informática
Sistema de Emergencias 911
Salta, Argentina
.



Relevant Pages