RFID Programming With VB.NET

旧时模样 提交于 2019-12-12 22:43:19

问题


I'm trying to use RFID Contactless Smart Card (T8/D8 Series) for my final project. But i have problem acessing the dcrf32.dll file in my form.

There are 3 things included in RFID Package, (therefore : 12 smartcards, an usb port, and a driver CD)

In the driver CD, there are so many sample project in some programming language, except VB.NET, i tried them one by one, and that's work.

There is a folder named "win32-dll", it have 3 files inside (dcrf32.dll, dcrf32.h, dcrf32.lib). I have to copy them all in every sample program that i want to use.

They also have example in VB.6, when i try to run it, no problems at all. It works. (i also put those 3 dcrf files in the %windows%\System32 folder).

But, when i try to build my own project with Visual Studio 2010 and using VB.NET programming language, i have a problem calling the dcrf32.dll file.

I migrate the VB6 source code to VB.NET, it has error when giving parameters to dc_init function. Can anybody help me? Where is my fault?

Here are the links that important to solve my problems : Here

I just need help with my first button, and you don't have to help me with the other button like in VB 6 example program.

I just wanna know how to connect the dcrf32 files, and why in VB.NET it has error but in VB 6 it works properly.

I wonder it.


回答1:


The problem that you are having is dealing with your Declare Functions and the fact there are changes to the size of integers and longs etc. in VB.Net. Look at this Link and this Code Project Article on using PInvoke.

i.e. An Integer in VB6 is a Short in VB.Net, A Long in VB6 is an Integer in VB.Net. The % in your Declares is a VB6 Integer and will become a short.

Declare Auto Function dc_init Lib "dcrf32.dll" (ByVal port as Short, ByVal baud As Integer) As Integer
Declare Auto Function dc_exit Lib "dcrf32.dll" (ByVal icdev As Integer) As Short
Declare Auto Function dc_request Lib "dcrf32.dll" (ByVal icdev As Integer, ByVal mode as Short, tagtype As Integer) As Short
Declare Auto Function dc_anticoll Lib "dcrf32.dll" (ByVal icdev As Integer, ByVal bcnt as Short, snr As Integer) As Short

...


来源:https://stackoverflow.com/questions/8337204/rfid-programming-with-vb-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!