SDK开发包怎么使

csts_002 2011-04-06 01:47:53
小弟在做一个Winform下的项目,其中用到了第二代身份证阅读器,品牌是“国腾GTICR100二代证”。。。

打开它的SDK,里面有“开发包”、“驱动包”、“样例源码”、和“函数包”使用手册,以及VB/VC/Deliphi的软件案例。。。ca,没有C#的。。。

看看它的开发包:

只有四个文件:termb.dll、WltRS.dll、gbk2gb13000、Nation.dat。。。

应该是把“termb.dll、WltRS.dll”在开发应用的时候添加进去就好了对吧。。。

C#的实力竟然是个“控制台程序”,而且只有读姓名和性别,不想其它VB/VC/Delephy的,什么都读出来了,而且是Winform下。。。

C#实例:


using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;


namespace ConsoleApplication1
{
class Program
{
[DllImport("termb.DLL", CallingConvention = CallingConvention.StdCall)]
public static extern int InitComm(int iPort);

[DllImport("termb.DLL", CallingConvention = CallingConvention.StdCall)]
public static extern int CloseComm();

[DllImport("termb.DLL", CallingConvention = CallingConvention.StdCall)]
public static extern int Authenticate();

[DllImport("termb.DLL", CallingConvention = CallingConvention.StdCall)]
public static extern int Read_Content(int iActive);

[DllImport("termb.DLL", CallingConvention = CallingConvention.StdCall)]
public static extern int GetPeopleName(Byte[] buf, int iLen);

[DllImport("termb.DLL", CallingConvention = CallingConvention.StdCall)]
public static extern int GetPeopleSex(Byte[] buf, int iLen);

[DllImport("termb.DLL", CallingConvention = CallingConvention.StdCall)]
public static extern int GetPeopleNation(StringBuilder buf, int iLen);

[DllImport("termb.DLL", CallingConvention = CallingConvention.StdCall)]
public static extern int GetPeopleBirthday(StringBuilder buf, int iLen);

[DllImport("termb.DLL", CallingConvention = CallingConvention.StdCall)]
public static extern int GetPeopleAddress(StringBuilder buf, int iLen);

[DllImport("termb.DLL", CallingConvention = CallingConvention.StdCall)]
public static extern int GetStartDate(StringBuilder buf, int iLen);

[DllImport("termb.DLL", CallingConvention = CallingConvention.StdCall)]
public static extern int GetEndDate(StringBuilder buf, int iLen);

static string GetName()
{
Byte[] asciiBytes = null;
asciiBytes = new Byte[100];
int dwRet = GetPeopleName(asciiBytes, 100);
Encoding gb2312 = Encoding.GetEncoding("gb2312");
char[] asciiChars = new char[gb2312.GetCharCount(asciiBytes, 0, dwRet)];
gb2312.GetChars(asciiBytes, 0, dwRet, asciiChars, 0);
return new string(asciiChars);
}

static string GetSex()
{
Byte[] asciiBytes = null;
asciiBytes = new Byte[100];
int dwRet = GetPeopleSex(asciiBytes, 100);
Encoding gb2312 = Encoding.GetEncoding("gb2312");
char[] asciiChars = new char[gb2312.GetCharCount(asciiBytes, 0, dwRet)];
gb2312.GetChars(asciiBytes, 0, dwRet, asciiChars, 0);
return new string(asciiChars);
}

static void Main(string[] args)
{

int i = InitComm(1);
i = Authenticate();
i = Read_Content(1);

string szValue = null;

szValue = GetName();
szValue = GetSex();
Console.Read();

}
}
}

小弟要把它改为Winform下的程序,请问照片应该怎样读???方法怎样写???

不太擅闯API啊。。。
...全文
1713 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
sswp7 2011-04-25
  • 打赏
  • 举报
回复
P/Invoke是什么:
平台调用服务,即P/Invoke是受控代码与非受控代码进行交互,使托管代码能够调用 DLL 中实现的非托管函数。

调用系统的 API 或与 COM 对象打交道,通过 System.Runtime.InteropServices 命名空间

为了从托管代码中调用非托管的DLL中函数,你要创建一个P/Invoke包装(Wrapper)。一个P/Invoke包装是一个.net兼 容的方法声明,用来创建P/Invoke包装的语法与创建托管
方法的声明语法本质上是一样的。唯一不同是P/Invoke包装不包含函数体,而只有方法 名、返回值类型和参数信息。并且,P/Invoke包装使用了DllImport属性。这个属性是用来
定位包含有目标函数的非托管的DLL。
缭绕飘渺 2011-04-07
  • 打赏
  • 举报
回复
winform和这个不一样吗
就是多个窗体而已
你把读到的值赋值给窗体上的控件不就完了吗
fanbingyuan 2011-04-07
  • 打赏
  • 举报
回复
还是打电话来的直接
sswp7 2011-04-07
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 caozhy 的回复:]

找到他们支持的电话号码,打电话问。

其他都不重要。
[/Quote]


+++++++++++++++++++

实在不行打电话问。。。
threenewbee 2011-04-06
  • 打赏
  • 举报
回复
找到他们支持的电话号码,打电话问。

其他都不重要。
shiling_02404 2011-04-06
  • 打赏
  • 举报
回复
控制台程序都能用了,winform里肯定有能用啊。你看看他的说明文档,示例中通过引入termb.DLL,就有很多相应的方法,再看一下另一个dll
Fibona 2011-04-06
  • 打赏
  • 举报
回复
查看他的API就全清楚了。示例只是简单的使用,你要用他的,肯定要知道他的API有那些,每一个API做什么,慢慢的看一看就OK了。

110,539

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧