哪位能提供 汇多考勤机Hd4e K/M 采集数据及删除数据方法? ( 积分: 200 )

  • 主题发起人 主题发起人 candyye
  • 开始时间 开始时间
C

candyye

Unregistered / Unconfirmed
GUEST, unregistred user!
在使用HD4E-K/M考勤机进行二次开发,哪位曾经开发过的给我一份参考!
扶我一把吧!E_mail:Candyye@21cn.com
他们的函数调用非常难,谢谢先!

如果有用此Conv.dll开发就更好了.我缺少此文件,哪位能提供给我?
function ICDMCommand(pDevice: Pointer; nAddress: Integer; ICDMCmd: Integer; lpSendData: pChar; lpRecvData: pChar): Integer; stdcall; external 'Conv.dll' name 'ICDMCommand';

以下我已经转化为delphi:
动态库ICDM.dll中包括以下函数:
void* OpenDevice(int nMyAddress, HWND hWnd)
void CloseDevice(void* pDevice)
void SetMyAddress(void* pDevice, int nAddress)
BOOL ConnectPort(void* pDevice, LPCTSTR lpCommDef)
BOOL IsConnect(void* pDevice)
void SetAddLog(void* pDevice, BOOL bAddLog)
void SetCommKey(void* pDevice, LPCTSTR lpCommKey)
void SetInnerCode (void* pDevice, BOOL bBig5)
BOOL DisConnectPort(void* pDevice)
void SetWaitTime(void* pDevice, DWORD dwWaitTime)
void* StartICDMCommand(void* pDevice, int nAddress, int nCommand,
void* pParameters = NULL, int nSizeOfParameter = 0)
int GetSizeOfData(void* pCommand)
BOOL GetData(void* pCommand, void* pDataBuffer, int nSize)
int GetCmdResult(void* pCommand)
void EndICDMCommand(void* pCommand)
void RecvEdition(LPTSTR lpEdition)
 
在使用HD4E-K/M考勤机进行二次开发,哪位曾经开发过的给我一份参考!
扶我一把吧!E_mail:Candyye@21cn.com
他们的函数调用非常难,谢谢先!

如果有用此Conv.dll开发就更好了.我缺少此文件,哪位能提供给我?
function ICDMCommand(pDevice: Pointer; nAddress: Integer; ICDMCmd: Integer; lpSendData: pChar; lpRecvData: pChar): Integer; stdcall; external 'Conv.dll' name 'ICDMCommand';

以下我已经转化为delphi:
动态库ICDM.dll中包括以下函数:
void* OpenDevice(int nMyAddress, HWND hWnd)
void CloseDevice(void* pDevice)
void SetMyAddress(void* pDevice, int nAddress)
BOOL ConnectPort(void* pDevice, LPCTSTR lpCommDef)
BOOL IsConnect(void* pDevice)
void SetAddLog(void* pDevice, BOOL bAddLog)
void SetCommKey(void* pDevice, LPCTSTR lpCommKey)
void SetInnerCode (void* pDevice, BOOL bBig5)
BOOL DisConnectPort(void* pDevice)
void SetWaitTime(void* pDevice, DWORD dwWaitTime)
void* StartICDMCommand(void* pDevice, int nAddress, int nCommand,
void* pParameters = NULL, int nSizeOfParameter = 0)
int GetSizeOfData(void* pCommand)
BOOL GetData(void* pCommand, void* pDataBuffer, int nSize)
int GetCmdResult(void* pCommand)
void EndICDMCommand(void* pCommand)
void RecvEdition(LPTSTR lpEdition)
 
用他的测试软件就可以了.
www.amass.com.cn
 
我二次开发的目的是程序某一时间自动收集到数据库,不想用他们的程序!
我想要的是如何调用他们的方法!
采集数据、删除数据!最好有实例给我,我看了他们编写的C程序,有好几个地方不明白。。。
 
我有HD2K, HD3k(4.0)的
 
TO BEYONDBILL:
能否给我一段收集数据代码或删除数据代码参考一下,好吗?

编写程序环境: winxp sp2  Delphi7
我收集数据的方式是按物理序号收取,出现不定时的出错。
 
unit CExample;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons, ICDMDLL, ExtCtrls, ComCtrls;

type
TFormTestSys = class(TForm)
ComboBoxComName: TComboBox;
BitBtnInit: TBitBtn;
BitBtnExit: TBitBtn;
EditTagAddress: TEdit;
LabelTagAddress: TLabel;
LabelSeriPortNum: TLabel;
GroupBox1: TGroupBox;
CheckBoxSetTime: TCheckBox;
CheckBoxDelInvaidcard: TCheckBox;
CheckBoxTest: TCheckBox;
CheckBoxSetDMGrade: TCheckBox;
CheckBoxReadLastResult: TCheckBox;
CheckBoxReadCardINFO: TCheckBox;
CheckBoxMFReadCardData: TCheckBox;
CheckBoxTMReadCardData: TCheckBox;
CheckBoxInitCardData: TCheckBox;
CheckBoxMFSeardhCard: TCheckBox;
CheckBoxMFModifyKey: TCheckBox;
CheckBoxTMModifyKEY: TCheckBox;
CheckBoxWriteUserPassword: TCheckBox;
CheckBoxDMBeep: TCheckBox;
CheckBoxAddInvaidCard: TCheckBox;
CheckBoxInItPointer: TCheckBox;
CheckBoxSetDMSort: TCheckBox;
CheckBoxDMStatus: TCheckBox;
CheckBoxRecord: TCheckBox;
CheckBoxWriteCardInfo: TCheckBox;
CheckBoxMFWriteCardData: TCheckBox;
CheckBoxTMWriteCardData: TCheckBox;
CheckBoxAddCardData: TCheckBox;
CheckBoxReduceCardData: TCheckBox;
CheckBoxMFVerifyKEY: TCheckBox;
CheckBoxTMVerifyKEY: TCheckBox;
CheckBoxVerifyUserPassord: TCheckBox;
CheckBoxModifyUserPassword: TCheckBox;
CheckBoxActiveTime: TCheckBox;
LabelSetTime: TLabel;
LabelDelInvaidCard: TLabel;
LabelTest: TLabel;
LabelDMGrade: TLabel;
LabelLastResult: TLabel;
LabelReadCardINFO: TLabel;
LabelMFReadCardData: TLabel;
LabelTMReadCardData: TLabel;
LabelInitCardData: TLabel;
LabelMFSearchCard: TLabel;
LabelMFModifyKey: TLabel;
LabelTMModifyKEY: TLabel;
LabelUserPassWord: TLabel;
LabelDMBeep: TLabel;
LabelAddInvaiDcard: TLabel;
LabelInitPointer: TLabel;
LabelSetDMSort: TLabel;
LabelDMStatus: TLabel;
LabelRecord: TLabel;
LabelWriteCardInfo: TLabel;
LabelMFWriteCardData: TLabel;
LabelTMWriteCardData: TLabel;
LabelAddCardData: TLabel;
LabelReduceCardData: TLabel;
LabelMFVerifyKEY: TLabel;
LabelTMVerifyKEY: TLabel;
LabelVerifyUserPassword: TLabel;
LabelModifyUserPassword: TLabel;
LabelActiveTime: TLabel;
Bevel1: TBevel;
LabelHeader: TLabel;
StatusBarDM: TStatusBar;
BitBtnTest: TBitBtn;
BitBtnClose: TBitBtn;
LabelDMSort: TLabel;
ComboBoxDMSort: TComboBox;
CheckBoxVoiceHint: TCheckBox;
LabelVoiceHint: TLabel;
IcdmCmd: TICDMDLL;
procedure BitBtnInitClick(Sender: TObject);
procedure BitBtnExitClick(Sender: TObject);
procedure BitBtnTestClick(Sender: TObject);
procedure FormShow(Sender: TObject);
private
{ Private declarations }
iTagAddress:Integer;

procedure FormInit();
public
{ Public declarations }
end;

var
FormTestSys: TFormTestSys;

implementation

{$R *.DFM}

procedure TFormTestSys.BitBtnInitClick(Sender: TObject);
begin
IcdmCmd.CommDef := 'Com' + ComboBoxComName.Text + ': baud=9600 parity=e data=9 stop=1';
If IcdmCmd.Link = True Then
StatusBarDM.SimpleText:='串口初始化成功!'
Else
StatusBarDM.SimpleText:='串口初始化失败!';
end;

procedure TFormTestSys.BitBtnExitClick(Sender: TObject);
begin
If IcdmCmd.DisLink Then
StatusBarDM.SimpleText :='断开连接成功!'
Else
StatusBarDM.SimpleText :='断开连接失败!';
end;

procedure TFormTestSys.BitBtnTestClick(Sender: TObject);
Var
bSetOK :BOOLEAN; //
iLoop :Integer; // 循环变量
iTestLength :Integer; // 测试时的数据长度;
iDMGrade :Integer; // 机具级别
iDMSort :Integer; // 机具类别
iSize :Integer; // 读取的数据长度
iRecordLeng :Integer; // 定长记录长度
iInvaidCard :Integer; // 非法卡号
iCount :Integer; // 取得记录条数
iInfoCode :Integer; // 返回信息代码
pDataBuffer :Pointer; // 存储信息缓冲区
pCardRecordBuffer :^CARDRECORD; // 打卡记录
rCardRecord :CardRecord;
pCardInfoBuffer :^CARDINFO; // 卡存储信息
rCardInfo :CardInfo;
pDMStatusBuffer :^DMSTATUS; // 机具状态
rDMStatus :DMStatus;
rDMBeep :BeepTime; // 机具鸣叫
iVoiceHintNum :Integer; // 语音提示

begin
iTestLength := 256;
iDMGrade := 1;
iDMSort := 0;
iRecordLeng := 8;
iInvaidCard := 12345;
iVoiceHintNum := 1;

StatusBarDM.SimpleText := '';
FormInit();//初始化界面
BitBtnTest.Enabled := FALSE;
BitBtnClose.Enabled := FALSE;

//------------------------------获得机具地址----------------------------//

iTagAddress := StrToInt(EditTagAddress.Text);

//--------------------------------广播较时------------------------------//

If CheckBoxSetTime.Checked = True Then
Begin
StatusBarDM.SimpleText := CheckBoxSetTime.Caption;
CheckBoxSetTime.Font.Color := clRed;

if not IcdmCmd.IsBusy() then
Begin
iInfoCode := IcdmCmd.StartCmd(iTagAddress, nSETTIME, nil, 0);
if iInfoCode = nSENDSUCCESS then
Begin
LabelSetTIME.Caption := '发送成功';
CheckBoxSetTime.Font.Color := clGreen;
End
Else
Begin
LabelSetTime.Caption := '未发送';
CheckBoxSetTime.Font.Color := clYellow;
End;
IcdmCmd.EndCmd();
End
Else
Begin
LabelSetTime.Caption := '未发送命令';
CheckBoxSetTime.Font.Color := clYellow;
End;
End;

//------------------------------通讯测试--------------------------------//

If CheckBoxTest.Checked = True Then
Begin
StatusBarDM.SimpleText:=CheckBoxTest.Caption;
CheckBoxTest.Font.Color := clRed;
If not IcdmCmd.IsBusy() then
Begin
iInfoCode := IcdmCmd.StartCmd(iTagAddress, nTEST, @iTestLength, SizeOf(Integer));
if iInfoCode = nSUCCESS then
Begin
labelTest.Caption := '测试成功';
CheckBoxTest.Font.Color := clGreen;
End
else
Begin
labelTest.Caption := '测试失败';
CheckBoxTest.Font.Color := clYellow;
End;
IcdmCmd.EndCmd();
End
Else
Begin
labelTest.Caption := '未发送命令';
CheckBoxTest.Font.Color := clYellow;
End;
End;

//--------------------------------设置机具类别--------------------------//

If CheckBoxSetDMSort.Checked = True Then
Begin
StatusBarDM.SimpleText:=CheckBoxSetDMSort.Caption;
iDMSort := 0;
CheckBoxSetDMSort.Font.Color := clRed;
If not IcdmCmd.IsBusy() then
Begin
iInfoCode := IcdmCmd.StartCmd(iTagAddress, nSetDMSort, @iDMSort, SizeOf(Integer));
if iInfoCode = nSUCCESS then
Begin
labelSetDMSort.Caption := '设置成功';
CheckBoxSetDMSort.Font.Color := clGreen;
End
else
Begin
labelSetDMSort.Caption := '设置失败';
CheckBoxSetDMSort.Font.Color := clYellow;
End;
IcdmCmd.EndCmd();
End
Else
Begin
labelSetDMSort.Caption := '未发送命令';
CheckBoxSetDMSort.Font.Color := clYellow;
End;
End;

//------------------------------设置机具级别----------------------------//

If CheckBoxSetDMGrade.Checked = True Then
Begin
StatusBarDM.SimpleText := CheckBoxSetDMGrade.Caption;
CheckBoxSetDMGrade.Font.Color := clRed;
If not IcdmCmd.IsBusy() then
Begin
iInfoCode := IcdmCmd.StartCmd(iTagAddress, nSetDMGrade, @iDMGrade, SizeOf(Integer));
if iInfoCode = nSUCCESS then
Begin
labelDMGrade.Caption := '设置成功';
CheckBoxSetDMGrade.Font.Color := clGreen;
End
else
Begin
labelDMGrade.Caption := '设置失败';
CheckBoxSetDMGrade.Font.Color := clYellow;
End;
IcdmCmd.EndCmd();
End
Else
Begin
labelDMGrade.Caption := '未发送命令';
CheckBoxSetDMGrade.Font.Color := clYellow;
End;
End;

//-----------------------------取所有记录-------------------------------//

If CheckBoxRecord.Checked = True Then
Begin
StatusBarDM.SimpleText := CheckBoxRecord.Caption;
CheckBoxRecord.Font.Color := clRed;
If not IcdmCmd.IsBusy() then
Begin
repeat
iInfoCode := IcdmCmd.StartCmd(iTagAddress, nRecord, @iRecordLeng, SizeOf(Integer));
if iInfoCode = nRECVSUCCESS then
Begin
iSize := IcdmCmd.GetSizeOfDatas();
iCount := iSize div SizeOf(CARDRECORD);
if iCount > 0 then
begin
GetMem(pDataBuffer, iSize);
IcdmCmd.GetDatas(pDataBuffer, iSize);
pCardRecordBuffer := pDataBuffer;
for iLoop := 1 to iCount do
begin
rCardRecord := pCardRecordBuffer^;
Inc(pCardRecordBuffer);
// UpdateDB(rCardRecord);//写入数据库
end;
FreeMem(pDataBuffer);
End;
End;
IcdmCmd.EndCmd;
until iInfoCode <> nRECVSUCCESS;

if iInfoCode = nRECVSUCCESS then
Begin
LabelRecord.Caption := '取到记录';
CheckBoxRecord.Font.Color := clGreen;
End
Else if iInfoCode = nRECVEMPTY then
Begin
LabelRecord.Caption := '取完记录';
CheckBoxRecord.Font.Color := clGreen;
End
Else
Begin
LabelRecord.Caption := '取记录失败';
CheckBoxRecord.Font.Color := clYellow;
End;
End
Else
Begin
LabelRecord.Caption := '未发送命令';
CheckBoxRecord.Font.Color := clYellow;
End;
End;

//-------------------------------写卡信息-------------------------------//

If CheckBoxWriteCardInfo.Checked = True Then
Begin
StatusBarDM.SimpleText := CheckBoxWriteCardInfo.Caption;
CheckBoxWriteCardInfo.Font.Color := clRed;
//-----------先设为发卡器---------------//
Begin
iDMSort := 2;
If not IcdmCmd.IsBusy() then
Begin
iInfoCode := IcdmCmd.StartCmd(iTagAddress, nSetDMSort, @iDMSort, SizeOf(Integer));
if iInfoCode = nSUCCESS then
Begin
bSetOK := TRUE;
End
else
Begin
bSetOK := FALSE;
End;
IcdmCmd.EndCmd();
End
Else
Begin
bSetOK := FALSE;
End;
End;

If bSetOK then
Begin
rCardInfo.nCardID := 12345;
rCardInfo.nRegion := 0;
rCardInfo.nPart := 99;
rCardInfo.nEmployID := 54321;
rCardInfo.nGrade := 1;
iInfoCode := ICDMCmd.StartCmd(iTagAddress, nWRITECARDINFO, @rCardInfo, Sizeof(rCardInfo));// 发送写卡信息命令
if iInfoCode = nSUCCESS then
Begin
LabelWriteCardINFO.Caption := '写卡成功';
CheckBoxWriteCardInfo.Font.Color := clGreen;
End
else
Begin
LabelWriteCardINFO.Caption := '写卡失败';
CheckBoxWriteCardInfo.Font.Color := clYellow;
End;
IcdmCmd.EndCmd();
End
Else
Begin
LabelWriteCardINFO.Caption := '未发送命令';
CheckBoxWriteCardInfo.Font.Color := clYellow;
End;
End;

//---------------------------------读卡信息-----------------------------//

If CheckBoxReadCardINFO.Checked = True Then
Begin
StatusBarDM.SimpleText := CheckBoxReadCardINFO.Caption;
CheckBoxReadCardINFO.Font.Color := clRed;
If not IcdmCmd.IsBusy() then
Begin
iInfoCode := IcdmCmd.StartCmd(iTagAddress, nReadCardInfo, nil, 0); // 发送读卡信息命令
if iInfoCode = nSUCCESS then
begin
//-----------取出卡中信息---------------//
iSize := IcdmCmd.GetSizeOfDatas();
GetMem(pDataBuffer, iSize);
IcdmCmd.GetDatas(pDataBuffer, iSize);
pCardInfoBuffer := pDataBuffer;
rCardInfo := pCardInfoBuffer^;
FreeMem(pDataBuffer);
LabelReadCardINFO.Caption := '读卡成功';
CheckBoxReadCardINFO.Font.Color := clGreen;
end
else
Begin
LabelReadCardINFO.Caption := '读卡失败';
CheckBoxReadCardINFO.Font.Color := clYellow;
End;
IcdmCmd.EndCmd();
End
Else
Begin
LabelReadCardINFO.Caption := '未发送命令';
CheckBoxReadCardINFO.Font.Color := clYellow;
End;
End;

//-------------------------------取机具状态-----------------------//

If CheckBoxDMStatus.Checked = True Then
Begin
StatusBarDM.SimpleText := CheckBoxDMStatus.Caption;
CheckBoxDMStatus.Font.Color := clRed;
If not IcdmCmd.IsBusy() then
Begin
iInfoCode := IcdmCmd.StartCmd(iTagAddress, nDMStatus, nil, 0);
if iInfoCode = nSUCCESS then
Begin
//-----------取出机具状态---------------//
iSize := IcdmCmd.GetSizeOfDatas();
GetMem(pDataBuffer, iSize);
IcdmCmd.GetDatas(pDataBuffer, iSize);
pDMStatusBuffer := pDataBuffer;
rDMStatus := pDMStatusBuffer^;
FreeMem(pDataBuffer);

LabelDMStatus.Caption := '取状态成功';
CheckBoxDMStatus.Font.Color := clGreen;
End
else
Begin
LabelDMStatus.Caption := '取状态失败';
CheckBoxDMStatus.Font.Color := clYellow;
End;
IcdmCmd.EndCmd;
End
Else
Begin
LabelDMStatus.Caption := '未发送命令';
CheckBoxDMStatus.Font.Color := clYellow;
End;
End;

//--------------------------------下载黑名单----------------------------//

If CheckBoxAddInvaidCard.Checked = True Then
Begin
StatusBarDM.SimpleText := CheckBoxAddInvaidCard.Caption;
CheckBoxAddInvaidCard.Font.Color := clRed;

if not IcdmCmd.IsBusy() then
Begin
iInfoCode := IcdmCmd.StartCmd(iTagAddress, nADDINVAIDCARD, @iInvaidCard, sizeof(Integer));
if iInfoCode = nSENDSUCCESS then
Begin
LabelAddInvaiDcard.Caption := '发送成功';
CheckBoxAddInvaidCard.Font.Color := clGreen;
End
Else
Begin
LabelAddInvaiDcard.Caption := '未发送';
CheckBoxAddInvaidCard.Font.Color := clYellow;
End;
IcdmCmd.EndCmd();
End
Else
Begin
LabelAddInvaiDcard.Caption := '未发送命令';
CheckBoxAddInvaidCard.Font.Color := clYellow;
End;
End;

//--------------------------------删除黑名单----------------------------//

If CheckBoxDelInvaidcard.Checked = True Then
Begin
StatusBarDM.SimpleText := CheckBoxDelInvaidcard.Caption;
CheckBoxDelInvaidcard.Font.Color := clRed;

if not IcdmCmd.IsBusy() then
Begin
iInfoCode := IcdmCmd.StartCmd(iTagAddress, nADDINVAIDCARD, @iInvaidCard, sizeof(Integer));
if iInfoCode = nSENDSUCCESS then
Begin
LabelDelInvaidCard.Caption := '发送成功';
CheckBoxDelInvaidcard.Font.Color := clGreen;
End
Else
Begin
LabelDelInvaidCard.Caption := '未发送';
CheckBoxDelInvaidcard.Font.Color := clYellow;
End;
IcdmCmd.EndCmd();
End
Else
Begin
LabelDelInvaidCard.Caption := '未发送命令';
CheckBoxDelInvaidcard.Font.Color := clYellow;
End;
End;

//-----------------------------取前次结果-----------------------------//

If CheckBoxReadLastResult.Checked = True Then
Begin
StatusBarDM.SimpleText := CheckBoxReadLastResult.Caption;
CheckBoxReadLastResult.Font.Color := clRed;
If not IcdmCmd.IsBusy() then
Begin
iInfoCode := IcdmCmd.StartCmd(iTagAddress, nLastStatus, nil, 0);
if iInfoCode = nSUCCESS then
Begin
LabelLastResult.Caption := '前次成功';
CheckBoxReadLastResult.Font.Color := clGreen;
End
else
Begin
LabelLastResult.Caption := '结果未知';
CheckBoxReadLastResult.Font.Color := clYellow;
End;
IcdmCmd.EndCmd;
End
Else
Begin
LabelLastResult.Caption := '未发送命令';
CheckBoxReadLastResult.Font.Color := clYellow;
End;
End;

//----------------------------初始化指针------------------------------//

If CheckBoxInitPointer.Checked = True Then
Begin
StatusBarDM.SimpleText:=CheckBoxInitPointer.Caption;
CheckBoxInitPointer.Font.Color := clRed;
If not IcdmCmd.IsBusy() then
Begin
iInfoCode := IcdmCmd.StartCmd(iTagAddress, nInitPointer, nil, 0);
if iInfoCode = nSUCCESS then
Begin
LabelInitPointer.Caption := '初始化成功';
CheckBoxInitPointer.Font.Color := clGreen;
End
else
Begin
LabelInitPointer.Caption := '初始化失败';
CheckBoxInitPointer.Font.Color := clYellow;
End;
IcdmCmd.EndCmd;
End
Else
Begin
LabelInitPointer.Caption := '未发送命令';
CheckBoxInitPointer.Font.Color := clYellow;
End;
End;

//-----------------------------机具鸣叫----------------------------//

If CheckBoxDMBeep.Checked = True Then
Begin
StatusBarDM.SimpleText := CheckBoxDMBeep.Caption;
CheckBoxDMBeep.Font.Color := clRed;
If not IcdmCmd.IsBusy() then
Begin
rDMBeep.nBeepTime := 0;
rDMBeep.nBeepTimes := 0;
rDMBeep.nBeepInterval := 0;
iInfoCode := IcdmCmd.StartCmd(iTagAddress, nBEEP, @rDMBeep, Sizeof(rDMBeep));
if iInfoCode = nSUCCESS then
Begin
LabelDMBeep.Caption := '鸣叫成功';
CheckBoxDMBeep.Font.Color := clGreen;
End
else
Begin
LabelDMBeep.Caption := '鸣叫失败';
CheckBoxDMBeep.Font.Color := clYellow;
End;
IcdmCmd.EndCmd;
End
Else
Begin
LabelDMBeep.Caption := '未发送命令';
CheckBoxDMBeep.Font.Color := clYellow;
End;
End;

//-----------------------------语音提示-------------------------------//

If CheckBoxVoiceHint.Checked = True Then
Begin
StatusBarDM.SimpleText := CheckBoxVoiceHint.Caption;
CheckBoxVoiceHint.Font.Color := clRed;
If not IcdmCmd.IsBusy() then
Begin
iInfoCode := IcdmCmd.StartCmd(iTagAddress, nSETVOICEHINT, @iVoiceHintNum, Sizeof(Integer));
if iInfoCode = nSUCCESS then
Begin
LabelVoiceHint.Caption := '语音提示成功';
CheckBoxVoiceHint.Font.Color := clGreen;
End
else
Begin
LabelVoiceHint.Caption := '语音提示失败';
CheckBoxVoiceHint.Font.Color := clYellow;
End;
IcdmCmd.EndCmd;
End
Else
Begin
LabelVoiceHint.Caption := '未发送命令';
CheckBoxVoiceHint.Font.Color := clYellow;
End;
End;

//----------------------------测试完后设置机具类别-----------------------//

Begin
iDMSort := ComboBoxDMSort.ItemIndex;
If not IcdmCmd.IsBusy() then
Begin
iInfoCode := IcdmCmd.StartCmd(iTagAddress, nSetDMSort, @iDMSort, SizeOf(Integer));
if iInfoCode = nSUCCESS then
Begin
StatusBarDM.SimpleText := '机具类别设置成功';
End
else
Begin
StatusBarDM.SimpleText := '机具类别设置失败';
End;
IcdmCmd.EndCmd();
End
Else
Begin
StatusBarDM.SimpleText := '未发送命令';
End;
End;
StatusBarDM.SimpleText := '测试完成';

BitBtnTest.Enabled := TRUE;
BitBtnClose.Enabled := TRUE;

End;

procedure TFormTestSys.FormShow(Sender: TObject);
begin
IcdmCmd.MyAddress := 100;//置本机地址
ComboBoxDMSort.ItemIndex := 0;
FormInit();
end;

procedure TFormTestSys.FormInit();
Begin
//------------------------------初始化界面------------------------------//
CheckBoxSetTime.Font.Color := clBlack;
LabelSetTime.Caption := '';

CheckBoxTest.Font.Color := clBlack;
LabelTest.Caption := '';

CheckBoxSetDMSort.Font.Color := clBlack;
LabelSetDMSort.Caption := '';

CheckBoxSetDMGrade.Font.Color := clBlack;
LabelDMGrade.Caption := '';

CheckBoxMFSeardhCard.Font.Color := clBlack;
LabelMFSearchCard.Caption := '';

CheckBoxRecord.Font.Color := clBlack;
LabelRecord.Caption := '';

CheckBoxReadCardINFO.Font.Color := clBlack;
LabelReadCardINFO.Caption := '';

CheckBoxWriteCardInfo.Font.Color := clBlack;
LabelWriteCardINFO.Caption := '';

CheckBoxDMStatus.Font.Color := clBlack;
LabelDMStatus.Caption := '';

CheckBoxMFWriteCardData.Font.Color:= clBlack;
LabelMFWriteCardData.Caption := '';

CheckBoxMFReadCardData.Font.Color:= clBlack;
LabelMFReadCardData.Caption := '';

CheckBoxTMWriteCardData.Font.Color:= clBlack;
LabelTMWriteCardData.Caption := '';

CheckBoxTMReadCardData.Font.Color:= clBlack;
LabelTMReadCardData.Caption := '';

CheckBoxAddCardData.Font.Color:= clBlack;
LabelAddCardData.Caption := '';

CheckBoxReduceCardData.Font.Color:= clBlack;
LabelReduceCardData.Caption := '';

CheckBoxAddInvaidCard.Font.Color := clBlack;
LabelAddInvaiDcard.Caption := '';

CheckBoxDelInvaidcard.Font.Color := clBlack;
LabelDelInvaidCard.Caption := '';

CheckBoxMFModifyKey.Font.Color := clBlack;
LabelMFModifyKey.Caption := '';

CheckBoxTMModifyKEY.Font.Color := clBlack;
LabelTMModifyKEY.Caption := '';

CheckBoxMFVerifyKEY.Font.Color := clBlack;
LabelMFVerifyKEY.Caption := '';

CheckBoxTMVerifyKEY.Font.Color := clBlack;
LabelTMVerifyKEY.Caption := '';

CheckBoxWriteUserPassword.Font.Color := clBlack;
LabelUserPassWord.Caption := '';

CheckBoxVerifyUserPassord.Font.Color := clBlack;
LabelVerifyUserPassword.Caption := '';

CheckBoxModifyUserPassword.Font.Color := clBlack;
LabelModifyUserPassword.Caption := '';

CheckBoxReadLastResult.Font.Color:= clBlack;
LabelLastResult.Caption := '';

CheckBoxInitCardData.Font.Color:= clBlack;
LabelInitCardData.Caption := '';

CheckBoxInItPointer.Font.Color:= clBlack;
LabelInitPointer.Caption := '';

CheckBoxDMBeep.Font.Color:= clBlack;
LabelDMBeep.Caption := '';

CheckBoxActiveTime.Font.Color:= clBlack;
LabelActiveTime.Caption := '';

CheckBoxVoiceHint.Font.Color:= clBlack;
LabelVoiceHint.Caption := '';
end;

end.
 
上面是把ICDM.DLL封装成类的,下面一个是直接调用的
unit CExample;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons, ExtCtrls, ComCtrls;

/////////////////////////////////////////////////////////////////////////
//结构定义
/////////////////////////////////////////////////////////////////////////
//枚举变量定义
type
TCardID = 0..99999;
TYear = 1999..2100;
TMonth = 1..12;
TDay = 1..31;
THour = 0..23;
TMinute = 0..59;

/////////////////////////////////////////////////////////////////////////
//卡存储信息结构
type CARDINFO = record
nCardID : Integer;
nInfoID : Integer;
nRegion, nPart, nGrade : Integer;
end;

/////////////////////////////////////////////////////////////////////////
//鸣叫
type BEEPTIME = record
nBeepTime : Integer;
nBeepTimes : Integer;
nBeepInterval : Integer;
end;

/////////////////////////////////////////////////////////////////////////
//打卡记录结构
type CARDRECORD = record
nInfoID : Integer;
nYear,nMonth, nDay : Integer;
nHour, nMinute : Integer;
end;

/////////////////////////////////////////////////////////////////////////
//机具状态结构
type DMSTATUS = record
nAddress : Integer;
nGrade,nSort : Integer;
nBeginPointer, nPresentPointer : Integer;
nRecordLength : Integer;
end;

type TKey = array[1..12] of Char;
/////////////////////////////////////////////////////////////////////////
//机具状态结构
type MFKEY = record
nAorBKey : Integer;
nSectorNum : Integer;
strOldKey : TKey;
strNewKey : TKey;
end;

/////////////////////////////////////////////////////////////////////////
//黑名单结构
type INVAIDCARDID = record
nCardID : Integer;
end;

type
TFormTestSys = class(TForm)
BitBtnInitSeriPort: TBitBtn;
BitBtnExitPort: TBitBtn;
EditTagAddress: TEdit;
Label1: TLabel;
Label2: TLabel;
GroupBox1: TGroupBox;
CheckBoxSetTime: TCheckBox;
CheckBoxDelInvaidcard: TCheckBox;
CheckBoxTest: TCheckBox;
CheckBoxSetDMGrade: TCheckBox;
CheckBoxReadLastResult: TCheckBox;
CheckBoxReadCardINFO: TCheckBox;
CheckBoxMFReadCardData: TCheckBox;
CheckBoxTMReadCardData: TCheckBox;
CheckBoxInitCardData: TCheckBox;
CheckBoxMFSeardhCard: TCheckBox;
CheckBoxMFModifyKey: TCheckBox;
CheckBoxTMModifyKEY: TCheckBox;
CheckBoxWriteUserPassword: TCheckBox;
CheckBoxDMBeep: TCheckBox;
CheckBoxAddInvaidCard: TCheckBox;
CheckBoxInItPointer: TCheckBox;
CheckBoxSetDMSort: TCheckBox;
CheckBoxDMStatus: TCheckBox;
CheckBoxRecord: TCheckBox;
CheckBoxWriteCardInfo: TCheckBox;
CheckBoxMFWriteCardData: TCheckBox;
CheckBoxTMWriteCardData: TCheckBox;
CheckBoxAddCardData: TCheckBox;
CheckBoxReduceCardData: TCheckBox;
CheckBoxMFVerifyKEY: TCheckBox;
CheckBoxTMVerifyKEY: TCheckBox;
CheckBoxVerifyUserPassord: TCheckBox;
CheckBoxModifyUserPassword: TCheckBox;
CheckBoxActiveTime: TCheckBox;
LabelSetTime: TLabel;
LabelDelInvaidCard: TLabel;
LabelTest: TLabel;
LabelDMGrade: TLabel;
LabelLastResult: TLabel;
LabelReadCardINFO: TLabel;
LabelMFReadCardData: TLabel;
LabelTMReadCardData: TLabel;
LabelInitCardData: TLabel;
LabelMFSearchCard: TLabel;
LabelMFModifyKey: TLabel;
LabelTMModifyKEY: TLabel;
LabelWriteUserPassword: TLabel;
LabelDMBeep: TLabel;
LabelAddInvaiDcard: TLabel;
LabelInitPointer: TLabel;
LabelSetDMSort: TLabel;
LabelDMStatus: TLabel;
LabelRecord: TLabel;
LabelWriteCardInfo: TLabel;
LabelMFWriteCardData: TLabel;
LabelTMWriteCardData: TLabel;
LabelAddCardData: TLabel;
LabelReduceCardData: TLabel;
LabelMFVerifyKEY: TLabel;
LabelTMVerifyKEY: TLabel;
LabelVerifyUserPassword: TLabel;
LabelModifyUserPassword: TLabel;
LabelActiveTime: TLabel;
Bevel1: TBevel;
Label32: TLabel;
StatusBarDM: TStatusBar;
BitBtnTest: TBitBtn;
BitBtnClose: TBitBtn;
Label3: TLabel;
ComboBoxDMSort: TComboBox;
CheckBoxSetVoiceHint: TCheckBox;
LabelSetVoiceHint: TLabel;
ComboBox_cominfo: TComboBox;
procedure BitBtnInitSeriPortClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure BitBtnExitPortClick(Sender: TObject);
procedure BitBtnTestClick(Sender: TObject);
procedure ComboBox_cominfoExit(Sender: TObject);
procedure FormShow(Sender: TObject);

private
{ Private declarations }
nTagAddress:Integer;
m_pDevice: Pointer;
m_pCommand: Pointer;
m_nMyAddress: Integer;
m_strCommDef: string;
bLink :Boolean;
bDisLink :Boolean;

procedure FormInit();

public
{ Public declarations }
end;

var
FormTestSys: TFormTestSys;

const
//---------------------------命令字定义-------------------------//

nSETTIME :Integer = 2; // 广播校时

nRECORD :Integer = 16; // 取下位机定长打卡记录
nRECORDRLT :Integer = 18; // 取下位机定长打卡记录确认帧
nLASTSTATUS :Integer = 20; // 取前次操作结果
nDMSTATUS :Integer = 22; // 取机具状态
nSETDMNUM :Integer = 24; // 设置机具号
nSETDMGRADE :Integer = 26; // 设置机具级别
nSETDMSORT :Integer = 28; // 设置机具类别
nSETSTORAGESORT :Integer = 30; // 设置记录存储满后的处理方式

nREADCARDINFO :Integer = 64; // 读卡信息
nWRITECARDINFO :Integer = 66; // 发卡
nMFSEARCHCARD :Integer = 68; // 寻卡(mifare卡)
nMFREADCARDDATA :Integer = 70; // 读数据块(mifare卡)
nMFWRITECARDDATA :Integer = 72; // 写数据块(mifare卡)
nTMREADCARDDATA :Integer = 74; // 读数据块(temic卡)
nTMWRITECARDDATA :Integer = 76; // 写数据块(temic卡)
nINITCARDDATA :Integer = 78; // 初始化块值
nADDCARDDATA :Integer = 80; // 块增值操作
nREDUCECARDDATA :Integer = 82; // 块减值操作

nTEST :Integer = 112; // 通讯测试
nINITPOINTER :Integer = 114; // 初始化数据区

nMFMODIFYKEY :Integer = 144; // mifare卡修改某一扇区密码
nMFVERIFYKEY :Integer = 146; // mifare卡验证某一扇区密码
nTMMODIFYKEY :Integer = 148; // temic卡修改密码
nTMVERIFYKE :Integer = 150; // temic卡验证密码
nWRITEUSERPASSWORD :Integer = 152; // 设置用户口令
nVERIFYUSERPASSWORD :Integer = 154; // 验证用户口令
nMODIFYUSERPASSWORD :Integer = 156; // 修改用户口令
nADDINVAIDCARD :Integer = 158; // 下载黑名单
nDELINVAIDCARD :Integer = 160; // 删除黑名单

nSETRELAYTIME :Integer = 192; // 设置继电器吸合时间
nBEEP :Integer = 194; // 设置蜂鸣时间
nSETSYSSORT :Integer = 196; // 设置系统类别
nSETVOICEHINT :Integer = 198; // 语音提示设置

/////////////////////////////////////////////////////////////////////////
//返回信息代码
nSENDSUCCESS :Integer = 0; // 发送成功
nCOMMERROR :Integer = 1; // 通讯错误
nFLAGERROR :Integer = 2; // 帧标志错误
nCHECKERROR :Integer = 3; // 检验错误
nNOTSEND :Integer = 4; // 未发送错误
nOVERTIME :Integer = 5; // 超时错误
nNOTRECVFRM :Integer = 6; // 未收到返回帧
nRECVFRM :Integer = 7; // 收到返回帧
nSUCCESS :Integer = 8; // 命令执行成功
nFAIL :Integer = 9; // 命令执行失败
nADRERROR :Integer = 10; // 返回地址错误
nCMDERROR :Integer = 11; // 返回命令字错误
nDATAERROR :Integer = 12; // 返回数据错误
nRECVEMPTY :Integer = 13; // 下位机记录取完
nRECVSUCCESS :Integer = 14; // 成功取记录

//-------------------------------------------------------------------------
//函数与过程定义

function OpenDevice(nMyAddress: Integer; hWnd: HWND): Pointer; stdcall; external 'icdm.dll' name 'OpenDevice';
procedure CloseDevice(pDevice: Pointer); stdcall; external 'icdm.dll' name 'CloseDevice';
function Connect(pDevice: Pointer; lpCommDef: pChar): Boolean stdcall; external 'icdm.dll' name 'Connect';
function IsConnect(pDevice: Pointer): Boolean stdcall; external 'icdm.dll' name 'IsConnect';
procedure SetAddLog(pDevice: Pointer; bAddLog: Boolean); stdcall; external 'icdm.dll' name 'SetAddLog';
function DisConnect(pDevice: Pointer): Boolean stdcall; external 'icdm.dll' name 'DisConnect';
function StartICDMCommand(pDevice: Pointer; nAddress: Integer; ICDMCmd: Integer; pPara: Pointer; nSize: Integer): Pointer; stdcall; external 'icdm.dll' name 'StartICDMCommand';
function GetSizeOfData(pCommand: Pointer): Integer; stdcall; external 'icdm.dll' name 'GetSizeOfData';
function GetData(pCommand: Pointer; pDataBuffer: Pointer; nSize: Integer): Boolean; stdcall; external 'icdm.dll' name 'GetData';
function GetCmdResult(pCommand: Pointer): Integer; stdcall; external 'icdm.dll' name 'GetCmdResult';
procedure EndICDMCommand(pCommand: Pointer); stdcall; external 'icdm.dll' name 'EndICDMCommand';

implementation

{$R *.DFM}

procedure TFormTestSys.FormCreate(Sender: TObject);
begin
m_nMyAddress := $64;
m_pCommand := nil;
m_pDevice := nil;
ComboBoxDMSort.ItemIndex := 0;
m_pDevice := OpenDevice(m_nMyAddress, Handle);
end;

procedure TFormTestSys.FormDestroy(Sender: TObject);
begin
DisConnect(m_pDevice);
CloseDevice(m_pDevice);
end;

procedure TFormTestSys.BitBtnInitSeriPortClick(Sender: TObject);
begin
m_strCommDef :='com' + ComboBox_cominfo.Text + ':baud=9600,parity=e,data=8,stop=1';
if m_pDevice <> nil then
begin
bLink := Connect(m_pDevice, PChar(m_strCommDef));
if bLink = TRUE then
begin
SetAddLog(m_pDevice, True);
StatusBarDM.SimpleText := '串口连接成功,添加日志! 请开始测试!';
end
else
StatusBarDM.SimpleText := '串口连接失败! 请重新连接!';
end
else
begin
bLink := FALSE;
StatusBarDM.SimpleText := '串口连接失败! 请重新启动程序!';
end;
end;

procedure TFormTestSys.BitBtnExitPortClick(Sender: TObject);
begin
if m_pDevice <> nil then
begin
bDisLink := DisConnect(m_pDevice);
if bDisLink = TRUE then
StatusBarDM.SimpleText :='断开连接成功!'
Else
StatusBarDM.SimpleText :='断开连接失败!';
end
else
begin
bDisLink := FALSE;
StatusBarDM.SimpleText := '串口关闭失败!';
end;
end;

procedure TFormTestSys.BitBtnTestClick(Sender: TObject);
Var
bSetOK :Boolean; //
nInfoCode :Integer; // 返回信息代码
nLoop :Integer; // 循环变量
nInvaidCard :Integer; // 黑名单
nTestLength :Integer; // 测试时的数据长度;
nDMGrade :Integer; // 机具级别
nDMSort :Integer; // 机具类别
nRecordLeng :Integer; // 定长记录长度
nSize :Integer; // 取得数据的字节数
nCount :Integer; // 取得记录条数
pDataBuffer :Pointer; // 存储信息缓冲区
pCardRecordBuffer :^CARDRECORD; // 打卡记录
rCardRecord :CardRecord;
pCardInfoBuffer :^CARDINFO; // 卡存储信息
rCardInfo :CardInfo;
pDMStatusBuffer :^DMSTATUS; // 机具状态
rDMStatus :DMStatus;
rBeepTest :BEEPTIME ; // 机具鸣叫
nVoiceHintNum :Integer; // 语音提示
rMFKey :MFKEY; // 修改密码
begin
nTestLength := 16;
nDMGrade := 1;
nDMSort := 0;
nRecordLeng := 4;
nVoiceHintNum := 1;
nInvaidCard := 12345;
bSetOK := FALSE;

StatusBarDM.SimpleText := '';
FormInit();//初始化界面
nTagAddress := StrToInt(EditTagAddress.Text);//获得机具地址
BitBtnTest.Enabled := FALSE;
BitBtnClose.Enabled := FALSE;

//-----------------------------广播较时---------------------------------//

If CheckBoxSetTime.Checked = True Then
Begin
StatusBarDM.SimpleText := CheckBoxSetTime.Caption;
CheckBoxSetTime.Font.Color := clYellow;
if blink then
Begin
m_pCommand := StartICDMCommand(m_pDevice,nTagAddress, nSETTIME, nil, 0);
if m_pCommand <> nil then
Begin
nInfoCode := GetCmdResult(m_pCommand);
if nInfoCode = nSENDSUCCESS then
Begin
LabelSetTIME.Caption := '发送成功!';
CheckBoxSetTime.Font.Color := clGreen;
End
Else
Begin
LabelSetTIME.Caption := '未发送!';
CheckBoxSetTime.Font.Color := clRed;
End;
End
Else
Begin
LabelSetTime.Caption := '命令失败!';
CheckBoxSetTime.Font.Color := clRed;
End;
EndICDMCommand(m_pCommand);
End
Else
Begin
LabelSetTime.Caption := '串口未连接!';
CheckBoxSetTime.Font.Color := clRed;
End;
End;

//---------------------------------通讯测试-----------------------------//

If CheckBoxTest.Checked = True Then
Begin
StatusBarDM.SimpleText := CheckBoxTest.Caption;
CheckBoxTest.Font.Color := clYellow;
If bLink then
Begin
m_pCommand := StartICDMCommand(m_pDevice,nTagAddress, nTEST, @nTestLength, SizeOf(Integer));
if m_pCommand <> nil then
begin
nInfoCode := GetCmdResult(m_pCommand);
if nInfoCode = nSUCCESS then
Begin
labelTest.Caption := '测试成功!';
CheckBoxTest.Font.Color := clGreen;
End
else
Begin
labelTest.Caption := '测试失败!';
CheckBoxTest.Font.Color := clRed;
End;
EndICDMCommand(m_pCommand);
End
Else
Begin
labelTest.Caption := '命令失败!';
CheckBoxTest.Font.Color := clRed;
End;
End
Else
Begin
labelTest.Caption := '串口未连接!';
CheckBoxTest.Font.Color := clRed;
End;
End;

//-------------------------------设置机具类别----------------------------//

if CheckBoxSetDMSort.Checked = True Then
Begin
StatusBarDM.SimpleText := CheckBoxSetDMSort.Caption;
CheckBoxSetDMSort.Font.Color := clYellow;
If bLink then
Begin
m_pCommand := StartICDMCommand(m_pDevice,nTagAddress, nSETDMSORT, @nDMSort, SizeOf(Integer));
if m_pCommand <> nil then
begin
nInfoCode := GetCmdResult(m_pCommand);
if nInfoCode = nSUCCESS then
Begin
labelSetDMSort.Caption := '类别设置成功!';
CheckBoxSetDMSort.Font.Color := clGreen;
End
else
Begin
labelSetDMSort.Caption := '类别设置失败!';
CheckBoxSetDMSort.Font.Color := clRed;
End;
EndICDMCommand(m_pCommand);
end
Else
Begin
labelSetDMSort.Caption := '命令失败!';
CheckBoxSetDMSort.Font.Color := clRed;
End;
end
Else
Begin
labelSetDMSort.Caption := '串口未连接!';
CheckBoxSetDMSort.Font.Color := clRed;
End;
End;

//-------------------------------设置机具级别---------------------------//

If CheckBoxSetDMGrade.Checked = True Then
Begin
StatusBarDM.SimpleText := CheckBoxSetDMGrade.Caption;
CheckBoxSetDMGrade.Font.Color := clYellow;
If bLink then
Begin
m_pCommand := StartICDMCommand(m_pDevice,nTagAddress, nSETDMGRADE, @nDMGrade, SizeOf(Integer));
if m_pCommand <> nil then
begin
nInfoCode := GetCmdResult(m_pCommand);
if nInfoCode = nSUCCESS then
Begin
labelDMGrade.Caption := '级别设置成功!';
CheckBoxSetDMGrade.Font.Color := clGreen;
End
else
Begin
labelDMGrade.Caption := '级别设置失败!';
CheckBoxSetDMGrade.Font.Color := clRed;
End;
EndICDMCommand(m_pCommand);
end
else
begin
labelDMGrade.Caption := '命令失败!';
CheckBoxSetDMGrade.Font.Color := clRed;
end;
end
Else
Begin
labelDMGrade.Caption := '串口未连接!';
CheckBoxSetDMGrade.Font.Color := clRed;
End;
End;

//--------------------------------取所有记录----------------------------//

If CheckBoxRecord.Checked = True Then
Begin
StatusBarDM.SimpleText := CheckBoxRecord.Caption;
CheckBoxRecord.Font.Color := clYellow;
nInfoCode := nCOMMERROR;
If bLink then
Begin
Repeat
m_pCommand := StartICDMCommand(m_pDevice,nTagAddress, nRECORD, @nRecordLeng, SizeOf(Integer));
if m_pCommand <> nil then
Begin
nInfoCode := GetCmdResult(m_pCommand);
if nInfoCode = nRECVSUCCESS then
begin
nSize := GetSizeOfData(m_pCommand);
nCount := nSize div SizeOf(CARDRECORD);
if nCount > 0 then
begin
GetMem(pDataBuffer, nSize);
GetData(m_pCommand, pDataBuffer, nSize);
pCardRecordBuffer := pDataBuffer;
for nLoop := 1 to nCount do
begin
rCardRecord := pCardRecordBuffer^;
Inc(pCardRecordBuffer);
// UpdateDB(rCardRecord);//写入数据库
end;
FreeMem(pDataBuffer);
End;
end;
EndICDMCommand(m_pCommand);
if nInfoCode = nRECVSUCCESS then
begin
m_pCommand := StartICDMCommand(m_pDevice,nTagAddress, nRECORDRLT, nil, 0);
EndICDMCommand(m_pCommand);
End
End;
Until nInfoCode <> nRECVSUCCESS;

if nInfoCode = nRECVEMPTY then
begin
LabelRecord.Caption := '记录取完!';
CheckBoxRecord.Font.Color := clGreen;
end
else if nInfoCode = nRECVSUCCESS then
begin
LabelRecord.Caption := '取到记录!';
CheckBoxRecord.Font.Color := clRed;
End
else
begin
LabelRecord.Caption := '取记录失败!';
CheckBoxRecord.Font.Color := clRed;
End;
end
else
begin
LabelRecord.Caption := '串口未连接!';
CheckBoxRecord.Font.Color := clRed;
end;
End;

//----------------------------------写卡信息----------------------------//

If CheckBoxWriteCardInfo.Checked = True Then
Begin
StatusBarDM.SimpleText := CheckBoxWriteCardInfo.Caption;
CheckBoxWriteCardInfo.Font.Color := clYellow;
//-----------先设为发卡器---------------//
Begin
nDMSort := 2;
m_pCommand := StartICDMCommand(m_pDevice,nTagAddress, nSETDMSORT, @nDMSort, SizeOf(Integer));
if m_pCommand <> nil then
Begin
nInfoCode := GetCmdResult(m_pCommand);
if nInfoCode = nSUCCESS then
bSetOK := TRUE
Else
bSetOK := FALSE;
EndICDMCommand(m_pCommand);
End;
End;

If bSetOK then
Begin
rCardInfo.nCardID := 10;
rCardInfo.nRegion := 10;
rCardInfo.nPart := 0;
rCardInfo.nInfoID := 10;
rCardInfo.nGrade := 1;
m_pCommand := StartICDMCommand(m_pDevice,nTagAddress, nWRITECARDINFO, @rCardInfo, SizeOf(rCardInfo));
if m_pCommand <> nil then
Begin
nInfoCode := GetCmdResult(m_pCommand);
if nInfoCode = nSUCCESS then
Begin
LabelWriteCardINFO.Caption := '写卡成功!';
CheckBoxWriteCardInfo.Font.Color := clGreen;
End
else
Begin
LabelWriteCardINFO.Caption := '写卡失败!';
CheckBoxWriteCardInfo.Font.Color := clRed;
End;
EndICDMCommand(m_pCommand);
End
Else
Begin
LabelWriteCardINFO.Caption := '命令失败!';
CheckBoxWriteCardInfo.Font.Color := clRed;
End;
End
Else
Begin
LabelWriteCardINFO.Caption := '串口未连接!';
CheckBoxWriteCardInfo.Font.Color := clRed;
End;
End;

//-----------------------------------读卡信息----------------------------//

If CheckBoxReadCardINFO.Checked=True Then
Begin
StatusBarDM.SimpleText := CheckBoxReadCardINFO.Caption;
CheckBoxReadCardINFO.Font.Color := clYellow;
If bLINK then
Begin
m_pCommand := StartICDMCommand(m_pDevice,nTagAddress, nReadCardInfo, nil, 0);// 发送读卡信息命令
if m_pCommand <> nil then
begin
nInfoCode := GetCmdResult(m_pCommand);
if nInfoCode = nRECVSUCCESS then
begin
//-----------取出卡中信息-----------//
nSize := GetSizeOfData(m_pCommand);
GetMem(pDataBuffer, nSize);
GetData(m_pCommand, pDataBuffer, nSize);
pCardInfoBuffer := pDataBuffer;
rCardInfo := pCardInfoBuffer^;
FreeMem(pDataBuffer);
LabelReadCardINFO.Caption := '读卡成功!';
CheckBoxReadCardINFO.Font.Color := clGreen;
End
else
Begin
LabelReadCardINFO.Caption := '读卡失败!';
CheckBoxReadCardINFO.Font.Color := clRed;
End;
EndICDMCommand(m_pCommand);
End
Else
Begin
LabelReadCardINFO.Caption := '命令失败!';
CheckBoxReadCardINFO.Font.Color := clRed;
End;
end
Else
Begin
LabelReadCardINFO.Caption := '串口未连接!';
CheckBoxReadCardINFO.Font.Color := clRed;
End;
End;

//--------------------------------取机具状态----------------------------//

If CheckBoxDMStatus.Checked = True Then
Begin
StatusBarDM.SimpleText := CheckBoxDMStatus.Caption;
CheckBoxDMStatus.Font.Color := clYellow;
If bLink then
Begin
m_pCommand := StartICDMCommand(m_pDevice,nTagAddress, nDMStatus, nil, 0);
if m_pCommand <> nil then
begin
nInfoCode := GetCmdResult(m_pCommand);
if nInfoCode = nRECVSUCCESS then
Begin
//-----------取出机具状态---------------//
nSize := GetSizeOfData(m_pCommand);
GetMem(pDataBuffer, nSize);
GetData(m_pCommand, pDataBuffer, nSize);
pDMStatusBuffer := pDataBuffer;
rDMStatus := pDMStatusBuffer^;
FreeMem(pDataBuffer);
LabelDMStatus.Caption := '取机具状态成功!';
CheckBoxDMStatus.Font.Color := clGreen;
End
else
Begin
LabelDMStatus.Caption := '取机具状态失败!';
CheckBoxDMStatus.Font.Color := clRed;
End;
EndICDMCommand(m_pCommand);
end
else
begin
LabelDMStatus.Caption := '命令失败!';
CheckBoxDMStatus.Font.Color := clRed;
end;
end
Else
begin
LabelDMStatus.Caption := '串口未连接!';
CheckBoxDMStatus.Font.Color := clRed;
end;
end;

//-----------------------------下载黑名单--------------------------------//

If CheckBoxAddInvaidCard.Checked = True Then
Begin
StatusBarDM.SimpleText := CheckBoxAddInvaidCard.Caption;
CheckBoxAddInvaidCard.Font.Color := clYellow;
if blink then
Begin
m_pCommand := StartICDMCommand(m_pDevice,nTagAddress, nADDINVAIDCARD, @nInvaidCard, Sizeof(Integer));
if m_pCommand <> nil then
Begin
nInfoCode := GetCmdResult(m_pCommand);
if nInfoCode = nSUCCESS then
Begin
LabelAddInvaiDcard.Caption := '下载成功!';
CheckBoxAddInvaidCard.Font.Color := clGreen;
End
Else
Begin
LabelAddInvaiDcard.Caption := '下载失败!';
CheckBoxAddInvaidCard.Font.Color := clRed;
End;
EndICDMCommand(m_pCommand);
End
Else
Begin
LabelAddInvaiDcard.Caption := '命令失败!';
CheckBoxAddInvaidCard.Font.Color := clRed;
End;
End
Else
Begin
LabelAddInvaiDcard.Caption := '串口未连接!';
CheckBoxAddInvaidCard.Font.Color := clRed;
End;
End;

//-----------------------------删除黑名单--------------------------------//

If CheckBoxDelInvaidCard.Checked = True Then
Begin
StatusBarDM.SimpleText := CheckBoxDelInvaidCard.Caption;
CheckBoxDelInvaidCard.Font.Color := clYellow;
if blink then
Begin
m_pCommand := StartICDMCommand(m_pDevice,nTagAddress, nDELINVAIDCARD, @nInvaidCard, Sizeof(Integer));
if m_pCommand <> nil then
Begin
nInfoCode := GetCmdResult(m_pCommand);
if nInfoCode = nSUCCESS then
Begin
LabelDelInvaiDcard.Caption := '删除成功!';
CheckBoxDelInvaidCard.Font.Color := clGreen;
End
Else
Begin
LabelDelInvaiDcard.Caption := '删除失败!';
CheckBoxDelInvaidCard.Font.Color := clRed;
End;
EndICDMCommand(m_pCommand);
End
Else
Begin
LabelDelInvaiDcard.Caption := '命令失败!';
CheckBoxDelInvaidCard.Font.Color := clRed;
End;
End
Else
Begin
LabelDelInvaiDcard.Caption := '串口未连接!';
CheckBoxDelInvaidCard.Font.Color := clRed;
End;
End;

//-----------------------------修改密码--------------------------------//

If CheckBoxMFModifyKey.Checked = True Then
Begin
StatusBarDM.SimpleText := CheckBoxMFModifyKey.Caption;
CheckBoxMFModifyKey.Font.Color := clYellow;
if blink then
Begin
rMFKey.nAorBKey := 0;
rMFKey.nSectorNum := 0;
rMFKey.strOldKey := 'FFFFFFFFFFFF';
rMFKey.strNewKey := 'FFFFFFFFFFFF';
m_pCommand := StartICDMCommand(m_pDevice,nTagAddress, nMFMODIFYKEY, @rMFKey, Sizeof(rMFKey));
if m_pCommand <> nil then
Begin
nInfoCode := GetCmdResult(m_pCommand);
if nInfoCode = nSUCCESS then
Begin
LabelMFModifyKey.Caption := '修改成功!';
CheckBoxMFModifyKey.Font.Color := clGreen;
End
Else
Begin
LabelMFModifyKey.Caption := '修改失败!';
CheckBoxMFModifyKey.Font.Color := clRed;
End;
EndICDMCommand(m_pCommand);
End
Else
Begin
LabelMFModifyKey.Caption := '命令失败!';
CheckBoxMFModifyKey.Font.Color := clRed;
End;
End
Else
Begin
LabelMFModifyKey.Caption := '串口未连接!';
CheckBoxMFModifyKey.Font.Color := clRed;
End;
End;

//---------------------------------取前次结果----------------------------//

If CheckBoxReadLastResult.Checked = True Then
Begin
StatusBarDM.SimpleText := CheckBoxReadLastResult.Caption;
CheckBoxReadLastResult.Font.Color := clYellow;
If bLink then
Begin
m_pCommand := StartICDMCommand(m_pDevice, nTagAddress, nLastStatus, nil, 0);
if m_pCommand <> nil then
begin
nInfoCode := GetCmdResult(m_pCommand);
if nInfoCode = nSUCCESS then
Begin
LabelLastResult.Caption := '取前次结果成功!';
CheckBoxReadLastResult.Font.Color := clGreen;
End
else
Begin
LabelLastResult.Caption := '取前次结果失败!';
CheckBoxReadLastResult.Font.Color := clRed;
End;
EndICDMCommand(m_pCommand);
End
Else
Begin
LabelLastResult.Caption := '命令失败!';
CheckBoxReadLastResult.Font.Color := clRed;
End;
end
Else
Begin
LabelLastResult.Caption := '串口未连接!';
CheckBoxReadLastResult.Font.Color := clRed;
End;
End;

//------------------------------初始化指针------------------------------//

If CheckBoxInitPointer.Checked = True Then
Begin
StatusBarDM.SimpleText := CheckBoxInitPointer.Caption;
CheckBoxInitPointer.Font.Color := clYellow;
If bLink then
Begin
m_pCommand := StartICDMCommand(m_pDevice,nTagAddress, nInitPointer, nil, 0);
if m_pCommand <> nil then
begin
nInfoCode := GetCmdResult(m_pCommand);
if nInfoCode = nSUCCESS then
Begin
LabelInitPointer.Caption := '初始化指针成功!';
CheckBoxInitPointer.Font.Color := clGreen;
End
else
Begin
LabelInitPointer.Caption := '初始化指针失败!';
CheckBoxInitPointer.Font.Color := clRed;
End;
EndICDMCommand(m_pCommand);
End
Else
Begin
LabelInitPointer.Caption := '命令失败!';
CheckBoxInitPointer.Font.Color:=clRed;
End;
end
Else
Begin
LabelInitPointer.Caption := '串口未连接!';
CheckBoxInitPointer.Font.Color:=clRed;
End;
End;

//------------------------------机具鸣叫测试-----------------------------//

if CheckBoxDMBeep.Checked = True then
begin
StatusBarDM.SimpleText := CheckBoxDMBeep.Caption;
CheckBoxDMBeep.Font.Color := clYellow;
if bLink then
begin
rBeepTest.nBeepTime := 0;
rBeepTest.nBeepTimes := 0;
rBeepTest.nBeepInterval := 0;
m_pCommand := StartICDMCommand(m_pDevice, nTagAddress, nBEEP, @rBeepTest, SizeOf(rBeepTest));
if m_pCommand <> nil then
begin
nInfoCode := GetCmdResult(m_pCommand);
if nInfoCode = nSUCCESS then
begin
LabelDMBeep.Caption := '鸣叫测试成功!';
CheckBoxDMBeep.Font.Color := clGreen;
end
else
begin
LabelDMBeep.Caption := '鸣叫测试失败!';
CheckBoxDMBeep.Font.Color := clRed;
end;
EndICDMCommand(m_pCommand);
end
else
begin
LabelDMBeep.Caption := '命令失败!';
CheckBoxDMBeep.Font.Color := clRed;
end;
end
Else
begin
LabelDMBeep.Caption := '串口未连接!';
CheckBoxDMBeep.Font.Color := clRed;
end;
end;

//-----------------------------语音提示-------------------------------//

If CheckBoxSetVoiceHint.Checked = True Then
Begin
StatusBarDM.SimpleText := CheckBoxSetVoiceHint.Caption;
CheckBoxSetVoiceHint.Font.Color := clRed;
If bLink then
Begin
m_pCommand := StartICDMCommand(m_pDevice, nTagAddress, nSETVOICEHINT, @nVoiceHintNum, SizeOf(Integer));
if m_pCommand <> nil then
begin
nInfoCode := GetCmdResult(m_pCommand);
if nInfoCode = nSUCCESS then
Begin
LabelSetVoiceHint.Caption := '语音提示成功';
CheckBoxSetVoiceHint.Font.Color := clGreen;
End
else
Begin
LabelSetVoiceHint.Caption := '语音提示失败';
CheckBoxSetVoiceHint.Font.Color := clYellow;
End;
EndICDMCommand(m_pCommand);
End
Else
Begin
LabelSetVoiceHint.Caption := '命令失败!';
CheckBoxSetVoiceHint.Font.Color := clYellow;
End;
End
Else
Begin
LabelSetVoiceHint.Caption := '串口未连接!';
CheckBoxSetVoiceHint.Font.Color := clYellow;
End;
End;

//----------------------------测试完后设置机具类别-----------------------//

Begin
nDMSort := ComboBoxDMSort.ItemIndex;
If bLink then
Begin
m_pCommand := StartICDMCommand(m_pDevice, nTagAddress, nSETDMSORT, @nDMSort, SizeOf(Integer));
if m_pCommand <> nil then
begin
nInfoCode := GetCmdResult(m_pCommand);
if nInfoCode = nSUCCESS then
Begin
StatusBarDM.SimpleText := '类别设置成功!';
End
else
Begin
StatusBarDM.SimpleText := '类别设置失败!';
End;
end
Else
Begin
StatusBarDM.SimpleText := '命令失败!';
End;
EndICDMCommand(m_pCommand);
end
Else
Begin
StatusBarDM.SimpleText := '串口未连接!';
End;
End;
StatusBarDM.SimpleText := '测试完成';

BitBtnTest.Enabled := TRUE;
BitBtnClose.Enabled := TRUE;

end;

procedure TFormTestSys.ComboBox_cominfoExit(Sender: TObject);
begin
m_strCommDef :='com' + ComboBox_cominfo.Text + ':baud=9600,parity=e,data=8,stop=1';
end;

procedure TFormTestSys.FormShow(Sender: TObject);
begin
FormInit();
end;

procedure TFormTestSys.FormInit();
Begin
CheckBoxSetTime.Font.Color :=clBlack;
LabelSetTime.Caption :='';

CheckBoxTest.Font.Color :=clBlack;
LabelTest.Caption :='';

CheckBoxSetDMGrade.Font.Color :=clBlack;
LabelDMGrade.Caption :='';

CheckBoxReadLastResult.Font.Color :=clBlack;
LabelLastResult.Caption :='';

CheckBoxReadCardINFO.Font.Color :=clBlack;
LabelReadCardINFO.Caption :='';

CheckBoxSetDMSort.Font.Color :=clBlack;
LabelSetDMSort.Caption :='';

CheckBoxWriteCardInfo.Font.Color :=clBlack;
LabelWriteCardINFO.Caption :='';

CheckBoxRecord.Font.Color :=clBlack;
LabelRecord.Caption :='';

CheckBoxDMStatus.Font.Color :=clBlack;
LabelDMStatus.Caption :='';

CheckBoxInItPointer.Font.Color :=clBlack;
LabelinItPointer.Caption :='';

CheckBoxMFSeardhCard.Font.Color :=clBlack;
LabelMFSearchCard.Caption :='';

CheckBoxMFWriteCardData.Font.Color :=clBlack;
LabelMFWriteCardData.Caption :='';

CheckBoxMFReadCardData.Font.Color :=clBlack;
LabelMFReadCardData.Caption :='';

CheckBoxTMWriteCardData.Font.Color :=clBlack;
LabelTMWriteCardData.Caption :='';

CheckBoxTMReadCardData.Font.Color :=clBlack;
LabelTMReadCardData.Caption :='';

CheckBoxAddCardData.Font.Color :=clBlack;
LabelAddCardData.Caption :='';

CheckBoxReduceCardData.Font.Color :=clBlack;
LabelReduceCardData.Caption :='';

CheckBoxAddInvaidCard.Font.Color :=clBlack;
LabelAddInvaidCard.Caption :='';

CheckBoxDelInvaidcard.Font.Color :=clBlack;
LabelDelInvaidcard.Caption :='';

CheckBoxMFModifyKey.Font.Color :=clBlack;
LabelMFModifyKey.Caption :='';

CheckBoxTMModifyKEY.Font.Color :=clBlack;
LabelTMModifyKEY.Caption :='';

CheckBoxMFVerifyKEY.Font.Color :=clBlack;
LabelMFVerifyKEY.Caption :='';

CheckBoxTMVerifyKEY.Font.Color :=clBlack;
LabelTMVerifyKEY.Caption :='';

CheckBoxWriteUserPassword.Font.Color :=clBlack;
LabelWriteUserPassword.Caption :='';

CheckBoxVerifyUserPassord.Font.Color :=clBlack;
LabelVerifyUserPassword.Caption :='';

CheckBoxModifyUserPassword.Font.Color :=clBlack;
LabelModifyUserPassword.Caption :='';

CheckBoxInitCardData.Font.Color :=clBlack;
LabelInitCardData.Caption :='';

CheckBoxDMBeep.Font.Color :=clBlack;
LabelDMBeep.Caption :='';

CheckBoxActiveTime.Font.Color :=clBlack;
LabelActiveTime.Caption :='';

CheckBoxSetVoiceHint.Font.Color :=clBlack;
LabelSetVoiceHint.Caption :='';
end;

end.
 
TO Beyondbill:
哗谢谢你,有你的例子就好办了。。。thanks
 
谢谢Beyondbill...
我已经成功调试好了,并能获取数据及删除数据。。。
你的例子是不是汇多提供给你的吗?好多地方都是C例子一样。。。
 
后退
顶部