public void Dispose() { try { CD_M1CardHeader.Sys_Close(ref g_hDevice); } catch { throw; } }
public override bool Intial() { try { int status; //=========================== Connect reader ========================= //Check whether the reader is connected or not if (true == CD_M1CardHeader.Sys_IsOpen(g_hDevice)) { //If the reader is already open , close it firstly status = CD_M1CardHeader.Sys_Close(ref g_hDevice); if (0 != status) { this.SendErrorInfo("Sys_Close failed !"); return(false); } } //Connect status = CD_M1CardHeader.Sys_Open(ref g_hDevice, 0, 0x0416, 0x8020); if (0 != status) { this.SendErrorInfo("Sys_Open failed !"); return(false); } //============= Init the reader before operating the card ============ //Close antenna of the reader status = CD_M1CardHeader.Sys_SetAntenna(g_hDevice, 0); if (0 != status) { this.SendErrorInfo("Sys_SetAntenna failed !"); // MessageBox.Show(strError, "error", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } CD_M1CardHeader.Sleep(5); //Appropriate delay after Sys_SetAntenna operating //Set the reader's working mode status = CD_M1CardHeader.Sys_InitType(g_hDevice, (byte)'A'); if (0 != status) { this.SendErrorInfo("Sys_InitType failed !"); return(false); } CD_M1CardHeader.Sleep(5); //Appropriate delay after Sys_InitType operating //Open antenna of the reader status = CD_M1CardHeader.Sys_SetAntenna(g_hDevice, 1); if (0 != status) { this.SendErrorInfo("Sys_SetAntenna failed !"); return(false); } CD_M1CardHeader.Sleep(5); //Appropriate delay after Sys_SetAntenna operating //============================ Success Tips ========================== //Beep 200 ms status = CD_M1CardHeader.Sys_SetBuzzer(g_hDevice, 20); if (0 != status) { this.SendErrorInfo("Sys_SetBuzzer failed !"); // MessageBox.Show(strError, "error", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } return(true); } catch { throw; } }