有 关ic卡的读取问题(100分)

  • 主题发起人 主题发起人 wqh0329
  • 开始时间 开始时间
W

wqh0329

Unregistered / Unconfirmed
GUEST, unregistred user!
我现在有一ic卡(包括读卡器.)随卡还附带了一个c做的test .demo.
可以读出该ic卡编号.每张ic卡都有自己唯一编号.
以及一个相关dll文件,和说明.

所要做的工作就是将该ic卡的编号通过读卡器读入到计算机中就行了.
但是我不知道用delphi如何做.
现在我将该dll说明文件粘贴出来.望大家帮帮忙,教教我这个还是菜鸟的
家伙.
串口动态链接库使用说明
此动态链接库为MFC标准静态链接,编译时只需要在程序中加入即可,使用时不需要其他MFC动态链接库。

此动态链接库输出函数为3个,分别介绍如下:

BOOL WINAPI InitComPort(HWND hWnd, UINT nPortNumber ,DWORD dwMsg,UINT nBaud,char cParity,UINT nDatabits,UINT nStopsbits,DWORD dwEvents,UINT nBufferSize);
此函数为串口初始化函数,各参数具体含义为:

HWND hWnd,主程序窗口句柄
UINT nPortNumber,串口号
DWORD dwMsg,主程序用来接收串口数据的消息处理函数的消息值
UINT nBaud,串口速率
char cParity, 奇偶校验位
UINT nDatabits,数据位
UINT nStopsbits,停止比特
DWORD dwEvents,串口响应的消息类型,设为读取数据
UINT nBufferSize,串口数据缓冲区

DCB GetDCB(UINT nPortNumber)
此函数为读取串口状态,参数为串口号

void ExitCommPort()
此函数为程序退出时,释放串口,可以在析构函数中使用。此函数使用不当可能会导致串口一直占用的状态

在标准MFC程序中使用如下:
在Project->settings->link->input->Object/library modules:中设置lib的全路径及文件名,如:
e:/work/testcom/debug/testcom.lib
在使用程序的头文件里加入如下声名:

extern "C"__declspec(dllimport)
BOOL WINAPI InitComPort(HWND pPortOwner, UINT portnr ,DWORD dwMsg,UINT baud,char parity,UINT databits,UINT stopsbits,DWORD dwCommEvents,UINT nBufferSize);
extern "C"__declspec(dllimport)
DCB GetDCB(UINT portnr);
extern "C"__declspec(dllimport)
void ExitCommPort();

主程序的消息响应函数的使用如下所示:(以提供的示例为例)

主程序头文件中加入消息声名
#define WM_COMM_RXCHAR WM_USER+200
在头文件的消息响应区加入响应函数
afx_msg LONG OnCommunication(UINT, LONG);
在c文件消息表中加入响应函数所对应的事件
ON_MESSAGE(WM_COMM_RXCHAR, OnCommunication)
在c文件中编写处理程序
LONG CTestDlg::OnCommunicatio

以上就是说明文件,我的要求,改为delphi 做的
dll?因为c,我不行.
该如何改,还请多指教


 
有传头文件为pas的东东,另外我以前写的IC卡程序有delphi的例子的呀改改就行了。
你用哪个公司的?
 
用明华奥汉的读卡器,它带有一个很全的例子,
其中有delphi的
 
哈哈。
ctx62兄的和我一样。
 
没有delphi的范例,只有c的.具体公司的,我一下忘记了.下午我会去问朋友,就可以知道了.
 
我把它的vc++范例粘贴出来.大家看看阿
// testDlg.cpp : implementation file
//

#include "stdafx.h"
#include "test.h"
#include "testDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
CAboutDlg();

// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA

// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL

// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
virtual void OnOK();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CTestDlg dialog

CTestDlg::CTestDlg(CWnd* pParent /*=NULL*/)
: CDialog(CTestDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CTestDlg)
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
m_ReadCharCount=0;
}

void CTestDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CTestDlg)
//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CTestDlg, CDialog)
//{{AFX_MSG_MAP(CTestDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_MESSAGE(WM_COMM_RXCHAR, OnCommunication)
ON_BN_CLICKED(IDC_CONFIGPORT1, OnConfigPort1)
ON_BN_CLICKED(IDC_CONFIGPORT2, OnConfigPort2)
ON_BN_CLICKED(IDC_CONFIGPORT3, OnConfigPort3)
ON_BN_CLICKED(IDC_CONFIGPORT4, OnConfigPort4)
ON_BN_CLICKED(IDC_EMPTYLIST1, OnEmptylist1)
ON_BN_CLICKED(IDC_EMPTYLIST2, OnEmptylist2)
ON_BN_CLICKED(IDC_EMPTYLIST3, OnEmptylist3)
ON_BN_CLICKED(IDC_EMPTYLIST4, OnEmptylist4)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CTestDlg message handlers

BOOL CTestDlg::OnInitDialog()
{
CDialog::OnInitDialog();

// Add "About..." menu item to system menu.

// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);

CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}

// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon

// TODO: Add extra initialization here
m_ListBox[0].SubclassDlgItem(IDC_LIST1, this);
m_ListBox[1].SubclassDlgItem(IDC_LIST2, this);
m_ListBox[2].SubclassDlgItem(IDC_LIST3, this);
m_ListBox[3].SubclassDlgItem(IDC_LIST4, this);


HWND hWnd=GetSafeHwnd();
for(int i=0;i<4;i++)
{
if(!InitComPort(hWnd, i+1,WM_COMM_RXCHAR ,9600,'N',8,1,EV_RXCHAR,20))
{

if(i==0)
{
GetDlgItem(IDC_CONFIGPORT1)->EnableWindow(FALSE);
GetDlgItem(IDC_EMPTYLIST1)->EnableWindow(FALSE);
}
else if(i==1)
{
GetDlgItem(IDC_CONFIGPORT2)->EnableWindow(FALSE);
GetDlgItem(IDC_EMPTYLIST2)->EnableWindow(FALSE);
}
else if(i==2)
{
GetDlgItem(IDC_CONFIGPORT3)->EnableWindow(FALSE);
GetDlgItem(IDC_EMPTYLIST3)->EnableWindow(FALSE);
}
else if(i==3)
{
GetDlgItem(IDC_CONFIGPORT4)->EnableWindow(FALSE);
GetDlgItem(IDC_EMPTYLIST4)->EnableWindow(FALSE);
}

}
}

return TRUE; // return TRUE unless you set the focus to a control
}

CTestDlg::~CTestDlg ()
{
ExitCommPort();
}
void CTestDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID &amp; 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}

// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.

void CTestDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting

SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&amp;rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;

// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}

// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CTestDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}


LONG CTestDlg::OnCommunication(WPARAM ch, LPARAM port)
{
if (port <= 0 || port > 4)
return -1;


CString string;
if((ch<16)&amp;&amp;(ch>=0))
string.Format ("0%X ",ch);
else
string.Format ("%X ",ch);
m_ReadString+=string;
m_ReadCharCount++;


if(m_ReadCharCount==7)
ReadNumber.ch [3]=ch;
if(m_ReadCharCount==8)
ReadNumber.ch [2]=ch;
if(m_ReadCharCount==9)
ReadNumber.ch [1]=ch;
if(m_ReadCharCount==10)
ReadNumber.ch [0]=ch;

if(m_ReadCharCount==11)
{
if(m_ListBox[port-1].GetCount ()==8)
m_ListBox[port-1].ResetContent ();


m_ListBox[port-1].AddString(m_ReadString);
m_ReadCharCount=0;

char buffer[20];
sprintf(buffer,"%010d",ReadNumber.i);
buffer[strlen(buffer)]='/0';

m_ListBox[port-1].AddString(buffer);

m_ListBox[port-1].SetSel(m_ListBox[port-1].GetCount()-1, TRUE);
m_ReadString.Empty ();
}
return 0;
}


void CTestDlg::OnConfigPort1()
{

CConfigDlog* dlg = new CConfigDlog(this, GetDCB(1));

HWND hWnd=GetSafeHwnd();
if (dlg->DoModal() == IDOK)
{
DWORD dwCommEvents = 0;
dwCommEvents |= EV_RXCHAR;

InitComPort(hWnd, 1,WM_COMM_RXCHAR,
atoi(dlg->m_strBaudRate),
dlg->m_strParity[0],
atoi(dlg->m_strDataBits),
atoi(dlg->m_strStopBits),
dwCommEvents,
20);
}
delete dlg;
}

void CTestDlg::OnConfigPort2()
{
// TODO: Add your control notification handler code here
CConfigDlog* dlg = new CConfigDlog(this, GetDCB(2));
HWND hWnd=GetSafeHwnd();
if (dlg->DoModal() == IDOK)
{
DWORD dwCommEvents = 0;
dwCommEvents |= EV_RXCHAR;

InitComPort(hWnd, 2,WM_COMM_RXCHAR,
atoi(dlg->m_strBaudRate),
dlg->m_strParity[0],
atoi(dlg->m_strDataBits),
atoi(dlg->m_strStopBits),
dwCommEvents,
20);
}
delete dlg;
}

void CTestDlg::OnConfigPort3()
{
// TODO: Add your control notification handler code here
CConfigDlog* dlg = new CConfigDlog(this, GetDCB(3));
HWND hWnd=GetSafeHwnd();
if (dlg->DoModal() == IDOK)
{
DWORD dwCommEvents = 0;
dwCommEvents |= EV_RXCHAR;

InitComPort(hWnd, 3,WM_COMM_RXCHAR,
atoi(dlg->m_strBaudRate),
dlg->m_strParity[0],
atoi(dlg->m_strDataBits),
atoi(dlg->m_strStopBits),
dwCommEvents,
20);

}
delete dlg;
}

void CTestDlg::OnConfigPort4()
{
// TODO: Add your control notification handler code here
CConfigDlog* dlg = new CConfigDlog(this, GetDCB(4));
HWND hWnd=GetSafeHwnd();
if (dlg->DoModal() == IDOK)
{
DWORD dwCommEvents = 0;
dwCommEvents |= EV_RXCHAR;

InitComPort(hWnd, 4,WM_COMM_RXCHAR,
atoi(dlg->m_strBaudRate),
dlg->m_strParity[0],
atoi(dlg->m_strDataBits),
atoi(dlg->m_strStopBits),
dwCommEvents,
20);
}
delete dlg;
}


void CTestDlg::OnEmptylist1()
{
// TODO: Add your control notification handler code here
m_ListBox[0].ResetContent();
}

void CTestDlg::OnEmptylist2()
{
// TODO: Add your control notification handler code here
m_ListBox[1].ResetContent();
}

void CTestDlg::OnEmptylist3()
{
// TODO: Add your control notification handler code here
m_ListBox[2].ResetContent();
}

void CTestDlg::OnEmptylist4()
{
// TODO: Add your control notification handler code here
m_ListBox[3].ResetContent();
}

void CAboutDlg::OnOK()
{
// TODO: Add extra validation here

CDialog::OnOK();
}
 
你用的是什么牌子的读卡器
 
原来大家都在搞这个??
我用的读卡器是我们自己做的。性能一般
希望能和楼上的几位大哥交流一下
 
qq 46543251
大家不如交流一下,当作交个朋友
 
我们用明华的读卡器
to biyesheng
你自己写核心的读写芯片吗?
to w1h0329
你引用这个库的函数 并做声明 不就 OK!
 
我用的是完美科技的。
用mscomm读卡。原来我的想法是读出一串字符,
接收这窜字符,然而,实际上只能是一个个字符
读取。我现在解决了,当时,让完美的给我了一个范例
解决了,不过我想暂时不结束这个问题。
当作大家进来交交朋友了,大家不反对把:)
呵呵,我有些赖帐了:)
 
我也刚买了一个跟你一样的读卡器
其实只要读串口就行了,就可以得到十一个字节的一串二进制数字,其中第七、八、九、十
个字节就是卡号,将二进制转成十进制或十六进制当卡号都行
我是用SPComm控件的,MSComm控件没找到,能告诉我在哪里吗?
另外,我没找到测试串口状态的函数,用什么来返回串口的状态?

欢迎交流
 
看了一下SPComm的源代码,解决了

只要判断其handle是不是0就可以知道
 
to inTrain:
不知道你用的是哪家的产品。 似乎是那种 ID卡! 呵呵!
我们做过几家 .
 
大家注意了,不要用深圳的 <<科艺嘉>>公司的,服务态度实在是差,刚送货给你时
什么都好说,当你钱给他了,他就对你不耐烦了。
我可吃大亏了,在他们的Dll上花了不少时间.
 
有谁能给我一份读写读卡器的例子,delphi的,
我现在要用这东西,先谢了!
E_mail:tang_717@163.com
 
我刚刚做了一个IC卡的读写软件,其实一点都不难,按所给的DLL中先打开串口,执行读卡
的操作,成功后,是设备处于等待状态,最后关闭软件时,关闭串口即可
 
to foxs:
能不能说的详细点。?
如果谁有读卡器的例子请也发给我一份。谢谢!
speedaway@163.com
 
unit ICIO;

interface

uses
Windows, forms;
function init_icrd:smallint; //初始化卡
function initia():smallint; //初始化外设
function writebase(cardno,status,name:pchar):smallint; //写基本信息
function writespare(times,classno,actday:pchar):smallint; //写花费
function writeconsume(classno,buydate:pchar):smallint; //写商品种类,花费时间
function writevalidity(validay:pchar):smallint; //写状态
function writecard(times:pchar):smallint; //写卡的时间
function readcardno:shortstring; //读卡号
function exit_icrd:smallint; //关闭外设
function readjlcard(start:integer;leng:integer):shortstring; //读教练员
function readjldata(start:integer;leng:integer):shortstring; //读数据
function writejlcard(start:integer;len:integer;str:pchar):integer; //写教练数据
procedure delay(msecs:longint);
function getcard_status():integer; //获得卡的状态
function readcardtime():shortstring; //读卡中剩余课时
function wrcardno(cardno:pchar):smallint; //写卡号
function readxycard(start:longint;len:longint):shortstring;
function writexycard(start:longint;len:longint;str:pchar):smallint;

function auto_init(port: smallint;baud:longint): longint;stdcall;external'MWIC_32.DLL';
function csc_4442(icdev: longint;length:smallint;password:pchar):smallint;stdcall;external 'MWIC_32.dll'; //核对密码
function asc_hex(asc:pchar;hex:pchar;len:smallint):smallint;stdcall;external 'MWIC_32.dll' name 'asc_hex'; //转换密码
function ic_exit(icdev: longint):smallint;stdcall;external 'MWIC_32.dll'; //关闭设备
function swr_4442(icdev: longint; offset:integer;len:integer;databuf:pchar): longint;stdcall;external'MWIC_32.DLL'; //写卡
function srd_4442(icdev: longint; offset:integer;len:integer;databuf:pchar): longint;stdcall;external'MWIC_32.DLL'; //读卡信息
function srd_24c16(icdev: longint; offset:integer;len:integer;databuf:pchar): longint;stdcall;external'MWIC_32.DLL';
function swr_24c16(icdev: longint; offset:integer;len:integer;databuf:pchar): longint;stdcall;external'MWIC_32.DLL';
function get_status(icdev:longint;state:pchar):smallint;stdcall;external'MWIC_32.DLL'; //读状态
var
icdev:longint;
st:integer;
databuff:array[0..1] of char;
implementation

//**********************
//初始化IC卡读写器
//**********************
function init_icrd:smallint;
var
password,password1:Array[0..5]of char;
begin
if initia()<0 then begin
//application.MessageBox('读写器初始化失败,不能对IC卡读写操作','五奥环软件',mb_ok);
init_icrd:=0;
exit;
end;
password:='123456';
st:=asc_hex(password,password1,3); //转换密码

st:=csc_4442(icdev,3,password1);
if st<>0 then begin //核对密码
application.MessageBox('读写器初始化失败,不能对IC卡读写操作','五奥环软件',mb_ok);
init_icrd:=0;
exit;
end;
init_icrd:=1;
end;

function initia():smallint;
var status:integer;
begin
icdev:=auto_init(0,9600);
if icdev<0 then begin
application.MessageBox('读写器初始化失败,不能对IC卡读写操作','五奥环软件',mb_ok);
initia:=-1;
exit;
end ;
status:=getcard_status;
if status=-1 then
begin
application.MessageBox('判断卡状态失败!','五奥环软件',mb_ok);
initia:=-1;
exit;
end;
if status=0 then
begin
application.MessageBox('读写器中没有插卡!','五奥环软件',mb_ok);
initia:=-1;
exit;
end;
initia:=1;
end;

//**********************
//写基础信息
//**********************
function writebase(cardno,status,name:pchar):smallint;
begin
st:=swr_4442(icdev,224,6,cardno);
if st<>0 then begin
application.MessageBox('学员编号写入IC卡失败','五奥环软件',mb_ok);
writebase:=0;
exit;
end;

st:=swr_4442(icdev,230,1,status);
if st<>0 then begin
application.MessageBox('IC卡状态写入失败','五奥环软件',mb_ok);
writebase:=0;
exit;
end;

st:=swr_4442(icdev,231,20,name);
if st<>0 then begin
application.MessageBox('学员姓名写入IC卡失败','五奥环软件',mb_ok);
writebase:=0;
exit;
end;
writebase:=1;
end;

//**********************
//写基础信息
//**********************
function wrcardno(cardno:pchar):smallint;
begin
st:=swr_4442(icdev,8,6,cardno);
if st<>0 then begin
application.MessageBox('学员卡号写入IC卡失败','五奥环软件',mb_ok);
wrcardno:=0;
exit;
end;
wrcardno:=1;
end;

//**********************
//写当前课时信息
//**********************
function writespare(times,classno,actday:pchar):smallint;
begin
st:=swr_4442(icdev,32,5,times);
if st<>0 then begin
application.MessageBox('课时数写入IC卡失败','五奥环软件',mb_ok);
writespare:=0;
exit;
end;

st:=swr_4442(icdev,42,3,classno);
if st<>0 then begin
application.MessageBox('课时编号写入IC卡失败','五奥环软件',mb_ok);
writespare:=0;
exit;
end;

st:=asc_hex(actday,databuff,1);
st:=swr_4442(icdev,45,1,databuff);
if st<>0 then begin
application.MessageBox('课时限定日期写入IC卡失败','五奥环软件',mb_ok);
writespare:=0;
exit;
end;
writespare:=1;
end;

//**********************
//写最近5次购卡信息
//**********************
function writeconsume(classno,buydate:pchar):smallint;
begin

writeconsume:=1;
end;

//****************************
//写入有效期
//****************************
function writevalidity(validay:pchar):smallint;
begin
st:=swr_4442(icdev,48,6,validay);
if st<>0 then begin
application.MessageBox('课时有效期写入IC卡失败','五奥环软件',mb_ok);
writevalidity:=0;
exit;
end;
writevalidity:=1;
end;

//**********************
//关闭IC卡读写器
//**********************
function exit_icrd:smallint;
begin
st:=ic_exit(icdev);
if st<>0 then begin
application.MessageBox('关闭通讯端口失败,不能对IC卡读写操作','五奥环软件',mb_ok);
exit_icrd:=0;
exit;
end
else
exit_icrd:=1;
end;

//**********************
//写当前剩余课时信息
//**********************
function writecard(times:pchar):smallint;
begin
st:=swr_4442(icdev,32,5,times);
if st<>0 then begin
application.MessageBox('剩余课时写入IC卡失败','五奥环软件',mb_ok);
writecard:=0;
exit;
end;
writecard:=1;
end;

//**********************
//读卡中会员号信息
//**********************
function readcardno:shortstring;
var
data:Array[0..5]of char;
begin
st:=srd_4442(icdev,224,6,data);
if st<>0 then begin
application.MessageBox('读IC卡失败','五奥环软件',mb_ok);
readcardno:='xxxxxx';
exit;
end;
readcardno:=data;

end;

//**********************
//读卡中剩余课时
//**********************
function readcardtime:shortstring;
var
data:Array[0..4]of char;
begin
st:=srd_4442(icdev,32,5,data);
if st<>0 then begin
application.MessageBox('读IC卡失败','五奥环软件',mb_ok);
readcardtime:='xxxxxx';
exit;
end;
readcardtime:=data;

end;
//**********************
//读教练员
//**********************
function readjlcard(start:integer;leng:integer):shortstring;
var
bzw:array [0..25] of char; //标志位
begin
//delay(10);
st:=srd_24c16(icdev,start,leng,bzw);
if st<>0 then begin
application.MessageBox('读IC卡失败','五奥环软件',mb_ok);
readjlcard:='0';
exit;
end;
readjlcard:=bzw;
end;

//读数据
function readjldata(start:integer;leng:integer):shortstring;
var
b:array [0..25] of char; //标志位
begin
//delay(10);
st:=srd_24c16(icdev,start,leng,b);
if st<>0 then begin
application.MessageBox('读IC卡失败','五奥环软件',mb_ok);
readjldata:='x';
exit;
end;
readjldata:=b;
end;

//写教练卡
function writejlcard(start:integer;len:integer;str:pchar):integer;
begin
delay(300);
st:=swr_24c16(icdev,start,len,str);
if st<0 then begin
application.MessageBox('写入教练卡失败','五奥环软件',mb_ok);
writejlcard:=-1;
exit;
end;
writejlcard:=1;
end;

function getcard_status():integer;
var state:integer;
begin
st:=get_status(icdev,@state);
if st<>0 then
begin
application.MessageBox('判断卡状态失败!','五奥环软件',mb_ok);
getcard_status:=-1;
exit;
end;
getcard_status:=state;
end;
//*********************
//延时
//*********************
procedure delay(msecs:longint);
var
firsttickcount,now:longint;
begin
firsttickcount:=gettickcount;
repeat
application.ProcessMessages;
now:=gettickcount;
until
(now-firsttickcount>=msecs) or (now<firsttickcount)
end;

//读学员卡
function readxycard(start:longint;len:longint):shortstring;
var
data:Array[0..7]of char;
begin
st:=srd_4442(icdev,start,len,data);
if st<>0 then begin
application.MessageBox('读IC卡失败','五奥环软件',mb_ok);
readxycard:='xxxxxx';
exit;
end;
readxycard:=data;
end;

function writexycard(start:longint;len:longint;str:pchar):smallint;
begin
st:=swr_4442(icdev,start,len,str);
if st<>0 then begin
application.MessageBox('写入IC卡失败','五奥环软件',mb_ok);
writexycard:=0;
exit;
end;
writexycard:=1;
end;
end.
其实很简单,Dll 中都把读和写的函数都声明了,你只要调用就可以,
重要的是知道卡的密码,卡中信息的格式,也就是数据的地址。
如果不知道,你可以用看看自带的demo查看一下。数据的地址,
你也可以自己定义。就这么多了,祝你成功。
 
后退
顶部