473,407 Members | 2,359 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Using DLL from a fingerprint detector in my VB - data type mismatch...?

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:
Expand|Select|Wrap|Line Numbers
  1. typedef struct _SYSTEMDATA 
  2.  unsigned char Version;  //DSP version 
  3.  unsigned char IP[4];   //IP address 
  4.  unsigned char NetMask[4];  //netmask 
  5.  unsigned char Gateway[4];  //gateway 
  6.  unsigned char BaudRate;  //baudrate for external 
  7.  unsigned char DeviceID[3];  //device ID 
  8.  unsigned short UserNo;  //user number 
  9.  unsigned long LogNo;  //log number 
  10.  unsigned char AuthenMode;  //1: 1-1  2: 1:1/1:N(<50 user
  11.  unsigned char UartMode;  //1:232, 2:485 
  12.  unsigned char VoiceEN;  //1:enable 
  13.  unsigned char ServerIP[3][4]; //server IP sets 
  14.  unsigned char IDLength;  //ID length for display 
  15.  unsigned char Reserved[20]; 
  16.  
  17.   DOORDATA  DoorData;  //door setting 
  18.  
  19.   unsigned char DeviceName[16];  //device name 
  20.   unsigned char HasDevice;    //this parameter should be 3 
  21.   unsigned char ProtocolPswd;  //protocol password 
  22.   unsigned char Reserved1[7]; 
  23. }SYSTEMDATA; //112 Bytes 
  24.  
  25. //door data structure 
  26. typedef struct _DOORDATA 
  27.   unsigned short DoorOpenSec; 
  28.   unsigned short DoorOverSec; 
  29.   unsigned short AlarmTime; 
  30.   unsigned char AlarmEnable;  //0: Disable 
  31.   unsigned char Reserved[9]; 
  32. }DOORDATA; //16 bytes

Now, i have been trying to define some variables that match the ones originally in the manual; below is this code:

Expand|Select|Wrap|Line Numbers
  1. Structure doordata
  2. Dim DoorOpenSec As Short
  3. Dim DoorOverSec As Short
  4. Dim AlarmTime As Short
  5. Dim AlarmEnable As String
  6. Dim Reserved As String
  7. End Structure
  8.  
  9. Structure SystemData
  10. Dim Version As String
  11. Dim IP As String
  12. Dim NetMask As String
  13. Dim Gateway As String
  14. Dim BaudRate As String
  15. Dim DeviceID As String
  16. Dim UserNo As Short
  17. Dim LogNo As Long
  18. Dim AuthenMode As String
  19. Dim UartMode As String
  20. Dim VoiceEN As String
  21. Dim ServerIP() As String
  22. Dim IDLength As String
  23. Dim Reserved As String
  24. Dim DoorData As doordata
  25. Dim DeviceName As String
  26. Dim HasDevice As String
  27. Dim ProtocolPswd As String
  28. Dim Reserved1 As String
  29. End Structure
  30.  
And the DLLImport i declared is as follows:
Expand|Select|Wrap|Line Numbers
  1. <DllImport("C:\WisClient.dll", EntryPoint:="Wis_Diagnose", SetLastError:=True, _ 
  2. CharSet:=CharSet.Unicode, ExactSpelling:=True, _
  3. CallingConvention:=CallingConvention.StdCall)> _
  4. Public Shared Function Diagnostico( _
  5. ByVal pwd As String, _
  6. ByRef systemdata As SystemData) _
  7. As Integer
  8. End Function
Now, sometimes, i got the folowing error:
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.

And all the time my Vstudio doesn't respond.... (an unhandled win32 exception...)
I think the problem is in the equivalences between the C and VB.NET data types...

I will really appreciate any comments that can help me solve this problems
Thanks in advance!!

EMilio Leyes
Salta, ARgentina
Jul 31 '08 #1
0 1295

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Joh | last post by:
Hello, (sorry long) i think i have missed something in the code below, i would like to design some kind of detector with python, but i feel totally in a no way now and need some advices to...
6
by: ASPfool | last post by:
Hello everyone, Please help me before I throw my computer out of the window: I'm working on a web application in classic ASP (vbscript), which is making calls to some webservices. The calls...
43
by: Gremlin | last post by:
If you are not familiar with the halting problem, I will not go into it in detail but it states that it is impossible to write a program that can tell if a loop is infinite or not. This is a...
2
by: PaJeeper | last post by:
I'm trying to write code that will automatically add a specified number of records to a table using variables derived from queries. I am attempting to do this with DAO. Background. I have...
5
by: junglist | last post by:
Hi guys, I've been trying to implement an editable datagrid and i have been succesful up to the point where i can update my datagrid row by row. However what used to happen was that once i updated...
1
by: amitbadgi | last post by:
I am getting the following error while converting an asp application to asp.net Exception Details: System.Runtime.InteropServices.COMException: Data type mismatch in criteria expression. ...
6
by: Scott M. Lyon | last post by:
As I mentioned in my other post, I'm attempting to, using COM Interop so I can update existing VB6 code to (for several specific functions) return a Hashtable from a .NET library. I've had...
2
by: psychomad | last post by:
Please, can someone help me out to solve this error, i've been searching throughout my codes and yet i didnt succeed in finding the error!!!! The Error is: Server Error in '/' Application....
19
by: Lysander | last post by:
I have written a query that takes three integers representing day,month and year, forms a date from them and compares this date to the date the record was entered and returns any records where the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.