using System;
using System.Runtime.InteropServices;
using static cn.mineki.Reader.IDCardReader;

namespace cn.mineki.Reader
{
    public class MKReader32
    {
        const String termb_x86 = @"3rd_lib\termb.dll";        

        #region 导入函数
        [DllImport(termb_x86, EntryPoint = "Buzzer", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern int Buzzer32(byte beepTime, byte waitTime, byte beepCount);

        [DllImport(termb_x86, EntryPoint = "InitComm", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern int InitComm32(ReaderPortNum port);

        [DllImport(termb_x86, EntryPoint = "CloseComm", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern int CloseComm32();

        [DllImport(termb_x86, EntryPoint = "Authenticate", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern int Authenticate32();

        [DllImport(termb_x86, EntryPoint = "Read_Content", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern int Read_Content32(int active);

        [DllImport(termb_x86, EntryPoint = "Read_Content_Path", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern int Read_Content_Path32(string path, int active);

        [DllImport(termb_x86, EntryPoint = "GetSAMID", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern int GetSAMID32([MarshalAs(UnmanagedType.LPArray)]byte[] id);

        [DllImport(termb_x86, EntryPoint = "TransApduCommand", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern int TransApduCommand32(ReaderSlotNum nReaderSlot, [MarshalAs(UnmanagedType.LPArray)]byte[] pSendDatas, int nSendLen, [MarshalAs(UnmanagedType.LPArray)]byte[] pRecvDatas, ref int nRecvLen);

        [DllImport(termb_x86, EntryPoint = "ActivateCard", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern int ActivateCard32(ReaderSlotNum nReaderSlot, [MarshalAs(UnmanagedType.LPArray)]byte[] pRecvDatas, ref int nRecvLen);

        [DllImport(termb_x86, EntryPoint = "SetAntPower", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern int SetAntPower32(int nPowerOn);

        #region ISO7816
        [DllImport(termb_x86, EntryPoint = "ISO7816_CardInsert", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern int ISO7816_CardInsert32(ReaderSlotNum nSlot);
        [DllImport(termb_x86, EntryPoint = "ISO7816_CardRemove", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern int ISO7816_CardRemove32(ReaderSlotNum nSlot);
        [DllImport(termb_x86, EntryPoint = "ISO7816_TransApdu", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern int ISO7816_TransApdu32(ReaderSlotNum nReaderSlot, [MarshalAs(UnmanagedType.LPArray)]byte[] pSendDatas, int nSendLen, [MarshalAs(UnmanagedType.LPArray)]byte[] pRecvDatas,ref int nRecvLen);
        #endregion

        [DllImport(termb_x86, EntryPoint = "ISO14443_TransApdu", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern int ISO14443_TransApdu32(ReaderSlotNum nReaderSlot, [MarshalAs(UnmanagedType.LPArray)]byte[] pSendDatas, int nSendLen, [MarshalAs(UnmanagedType.LPArray)]byte[] pRecvDatas, ref int nRecvLen);

        #region 机读旅行证件相关函数       
        [DllImport(termb_x86, EntryPoint = "EPP_GetInfo", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern int EPP_GetInfo32(ref EPP_Info pInfo);

        [DllImport(termb_x86, EntryPoint = "EPP_Authentication", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern int EPP_Authentication32(string pn, string bod, string eod);

        [DllImport(termb_x86, EntryPoint = "EPP_Read_Content", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern int EPP_Read_Content32(int active);

        [DllImport(termb_x86, EntryPoint = "EPP_Read_Content_Path", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern int EPP_Read_Content_Path32(string cPath, int active);
        #endregion

        #region 读取银行卡       
        [DllImport(termb_x86, EntryPoint = "BC_Read_Content", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern int BC_Read_Content32(ref BC_INFO info);
        #endregion

        #region 读取社保卡
        [DllImport(termb_x86, EntryPoint = "SSC_Authentication", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern int SSC_Authentication32(ReaderSlotNum nReaderSlot);

        [DllImport(termb_x86, EntryPoint = "SSC_Read_Content", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern int SSC_Read_Content32(ReaderSlotNum nReaderSlot, ref SSC_INFO info);
        #endregion

        #region 读取电子身份证
        //---------------------------------------------------------------------------
        [DllImport(termb_x86, EntryPoint = "EID_Authentication", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern int EID_Authentication32([MarshalAs(UnmanagedType.LPArray)]byte[] byEidCardID);

        [DllImport(termb_x86, EntryPoint = "EID_Read_Content", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern int EID_Read_Content32([MarshalAs(UnmanagedType.LPArray)]byte[] byEidCardID);
        #endregion

        #region  ISO15693标签
        [DllImport(termb_x86, EntryPoint = "ISO15693_ReadSingleBlock", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern int ISO15693_ReadSingleBlock32(bool readSecSta, int nBlkAddr, [MarshalAs(UnmanagedType.LPArray)]byte[] bufBlockDat, int nSize, ref int bytesBlkDatRead);

        [DllImport(termb_x86, EntryPoint = "ISO15693_WriteSingleBlock", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern int ISO15693_WriteSingleBlock32(int blkAddr, [MarshalAs(UnmanagedType.LPArray)]byte[] newBlkData, int bytesToWrite);

        [DllImport(termb_x86, EntryPoint = "ISO15693_ReadMultiBlocks", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern int ISO15693_ReadMultiBlocks32(bool readSecSta, int nBlkAddr, int numOfBlksToRead, ref int numOfBlksRead, [MarshalAs(UnmanagedType.LPArray)]byte[] bufBlockDat, int nSize, ref int bytesBlkDatRead);

        [DllImport(termb_x86, EntryPoint = "ISO15693_WriteMultipleBlocks", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern int ISO15693_WriteMultipleBlocks32(int blkAddr, int numOfBlks, [MarshalAs(UnmanagedType.LPArray)]byte[] newBlkData, int bytesToWrite);

        [DllImport(termb_x86, EntryPoint = "ISO15693_GetBlockSecStatus", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern int ISO15693_GetBlockSecStatus32(int blkAddr, int numOfBlks, [MarshalAs(UnmanagedType.LPArray)]byte[] bufBlkSecs, int nSize, ref int bytesSecRead);

        [DllImport(termb_x86, EntryPoint = "ISO15693_GetSystemInfo", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern int ISO15693_GetSystemInfo32([MarshalAs(UnmanagedType.LPArray)]byte[] uid, ref byte dsfid, ref byte afi, ref int blkSize, ref int numOfBloks, ref byte icRef);

        [DllImport(termb_x86, EntryPoint = "ISO15693_LockMultipleBlocks", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern int ISO15693_LockMultipleBlocks32(int blkAddr, int numOfBlks);

        [DllImport(termb_x86, EntryPoint = "ISO15693_WriteAFI", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern int ISO15693_WriteAFI32(byte afi);

        [DllImport(termb_x86, EntryPoint = "ISO15693_LockAFI", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern int ISO15693_LockAFI32();

        [DllImport(termb_x86, EntryPoint = "ISO15693_WriteDSFID", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern int ISO15693_WriteDSFID32(byte dsfid);

        [DllImport(termb_x86, EntryPoint = "ISO15693_LockDSFID", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern int ISO15693_LockDSFID32();

        [DllImport(termb_x86, EntryPoint = "ISO15693_Inventory", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern int ISO15693_Inventory32(byte afi, [MarshalAs(UnmanagedType.LPArray)]byte[] bufUids, int nSize, ref int bytesUidNums);
        #endregion
        
        #region MIFARE卡相关函数
        //---------------------------------------------------------------------------
        //MIFARE卡相关函数
        //---------------------------------------------------------------------------
        [DllImport(termb_x86, EntryPoint = "MIFARE_Authentication", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern int MIFARE_Authentication32(byte bSectorNo, byte[] pbKeyA, byte[] pbKeyB);
        [DllImport(termb_x86, EntryPoint = "MIFARE_ReadData", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern int MIFARE_ReadData32(byte bBlock, [MarshalAs(UnmanagedType.LPArray)]byte[] data, int nLen);
        [DllImport(termb_x86, EntryPoint = "MIFARE_WrtieData", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern int MIFARE_WrtieData32(byte bBlock, byte[] data, int nLen);
        [DllImport(termb_x86, EntryPoint = "MIFARE_IncrementValue", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern int MIFARE_IncrementValue32(byte bBlock, int nValue);
        [DllImport(termb_x86, EntryPoint = "MIFARE_DecrementValue", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern int MIFARE_DecrementValue32(byte bBlock, int nValue);
        [DllImport(termb_x86, EntryPoint = "MIFARE_ReadValue", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern int MIFARE_ReadValue32(byte bBlock, ref int pnValue);
        [DllImport(termb_x86, EntryPoint = "MIFARE_InitValue", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern int MIFARE_InitValue32(byte bBlock, int nValue);
        [DllImport(termb_x86, EntryPoint = "MIFARE_WriteSectorTrailer", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern int MIFARE_WriteSectorTrailer32(byte bBlock, byte[] pbKEYA, byte[] pbKEYB, byte[] pbAccessBits);
        #endregion

        #region 第二代居民身份证
        [DllImport(termb_x86, EntryPoint = "GetName2", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern bool GetName32([MarshalAs(UnmanagedType.LPArray)]byte[] sName, ref int nLen);

        [DllImport(termb_x86, EntryPoint = "GetSex2", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern bool GetSex32([MarshalAs(UnmanagedType.LPArray)]byte[] sBuf, ref int nLen);

        [DllImport(termb_x86, EntryPoint = "GetNation2", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern bool GetNation32([MarshalAs(UnmanagedType.LPArray)]byte[] sBuf, ref int nLen);

        [DllImport(termb_x86, EntryPoint = "GetBornDate2", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern bool GetBornDate32([MarshalAs(UnmanagedType.LPArray)]byte[] sBuf, ref int nLen);

        [DllImport(termb_x86, EntryPoint = "GetAddress2", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern bool GetAddress32([MarshalAs(UnmanagedType.LPArray)]byte[] sBuf, ref int nLen);

        [DllImport(termb_x86, EntryPoint = "GetIDNo2", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern bool GetIDNo32([MarshalAs(UnmanagedType.LPArray)]byte[] sBuf, ref int nLen);

        [DllImport(termb_x86, EntryPoint = "GetSignGov2", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern bool GetSignGov32([MarshalAs(UnmanagedType.LPArray)]byte[] sBuf, ref int nLen);

        [DllImport(termb_x86, EntryPoint = "GetStartDate2", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern bool GetStartDate32([MarshalAs(UnmanagedType.LPArray)]byte[] sBuf, ref int nLen);

        [DllImport(termb_x86, EntryPoint = "GetEndDate2", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern bool GetEndDate32([MarshalAs(UnmanagedType.LPArray)]byte[] sBuf, ref int nLen);

        [DllImport(termb_x86, EntryPoint = "GetNewAddress2", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern bool GetNewAddress32([MarshalAs(UnmanagedType.LPArray)]byte[] sBuf, ref int nLen);       

        [DllImport(termb_x86, EntryPoint = "GetFingerPrint", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern bool GetFingerPrint32([MarshalAs(UnmanagedType.LPArray)]byte[] sBuf, ref int nLen);
                
        [DllImport(termb_x86, EntryPoint = "MakeIDCardImages", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern bool MakeIDCardImages32(string sHead,string sIDCardImageFace,string sIDCardImageBack);

        [DllImport(termb_x86, EntryPoint = "GetPhoto", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern bool GetPhoto32([MarshalAs(UnmanagedType.LPArray)]byte[] sBuf, ref int nLen);
        #endregion

        #region 外国人永久居住证
        [DllImport(termb_x86, EntryPoint = "IsFPRIDCard", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern int IsFPRIDCard32();//是否是外国人居住证

        [DllImport(termb_x86, EntryPoint = "GetFPR_ENName2", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern bool GetFPR_ENName32([MarshalAs(UnmanagedType.LPArray)]byte[] sBuf, ref int nLen);//英文名

        [DllImport(termb_x86, EntryPoint = "GetFPR_SEX2", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern bool GetFPR_SEX32([MarshalAs(UnmanagedType.LPArray)]byte[] sBuf, ref int nLen);//性别

        [DllImport(termb_x86, EntryPoint = "GetFPR_IDNo2", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern bool GetFPR_IDNo32([MarshalAs(UnmanagedType.LPArray)]byte[] sBuf, ref int nLen);//身份证号

        [DllImport(termb_x86, EntryPoint = "GetFPR_NationCode2", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern bool GetFPR_NationCode32([MarshalAs(UnmanagedType.LPArray)]byte[] sBuf, ref int nLen);//国籍代码

        [DllImport(termb_x86, EntryPoint = "GetFPR_Nation2", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern bool GetFPR_Nation32([MarshalAs(UnmanagedType.LPArray)]byte[] sBuf, ref int nLen);//国籍代码中文()

        [DllImport(termb_x86, EntryPoint = "GetFPR_CHNName2", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern bool GetFPR_CHNName32([MarshalAs(UnmanagedType.LPArray)]byte[] sBuf, ref int nLen);//中文姓名

        [DllImport(termb_x86, EntryPoint = "GetFPR_ValidStartDate2", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern bool GetFPR_ValidStartDate32([MarshalAs(UnmanagedType.LPArray)]byte[] sBuf, ref int nLen);//证件签发时间

        [DllImport(termb_x86, EntryPoint = "GetFPR_ValidEndDate2", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern bool GetFPR_ValidEndDate32([MarshalAs(UnmanagedType.LPArray)]byte[] sBuf, ref int nLen);//证件终止时间

        [DllImport(termb_x86, EntryPoint = "GetFPR_Birthday2", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern bool GetFPR_Birthday32([MarshalAs(UnmanagedType.LPArray)]byte[] sBuf, ref int nLen);//出生日期

        [DllImport(termb_x86, EntryPoint = "GetFPR_IDVersion2", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern bool GetFPR_IDVersion32([MarshalAs(UnmanagedType.LPArray)]byte[] sBuf, ref int nLen);//证件版本号

        [DllImport(termb_x86, EntryPoint = "GetFPR_IssuingAuthorityCode2", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern bool GetFPR_IssuingAuthorityCode32([MarshalAs(UnmanagedType.LPArray)]byte[] sBuf, ref int nLen);//当次申请受理机关代码

        [DllImport(termb_x86, EntryPoint = "GetFPR_IDType2", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern bool GetFPR_IDType32([MarshalAs(UnmanagedType.LPArray)]byte[] sBuf, ref int nLen);//证件类型标识
        #endregion

        #region 新版外国人永久居住证相关函数
        [DllImport(termb_x86, EntryPoint = "IsFPR2IDCard", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern int IsFPR2IDCard32();//是否是外国人居住证
        [DllImport(termb_x86, EntryPoint = "GetFPR2_CHNName2", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern bool GetFPR2_CHNName32([MarshalAs(UnmanagedType.LPArray)]byte[] sBuf, ref int nLen);//中文姓名
        [DllImport(termb_x86, EntryPoint = "GetFPR2_SexCode2", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern bool GetFPR2_SexCode32([MarshalAs(UnmanagedType.LPArray)]byte[] sBuf, ref int nLen);//性别代码
        [DllImport(termb_x86, EntryPoint = "GetFPR2_RenewalTimes2", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern bool GetFPR2_RenewalTimes32([MarshalAs(UnmanagedType.LPArray)]byte[] sBuf, ref int nLen);//换证次数        
        [DllImport(termb_x86, EntryPoint = "GetFPR2_Birthday2", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern bool GetFPR2_Birthday32([MarshalAs(UnmanagedType.LPArray)]byte[] sBuf, ref int nLen);
        [DllImport(termb_x86, EntryPoint = "GetFPR2_ENName2", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern bool GetFPR2_ENName32([MarshalAs(UnmanagedType.LPArray)]byte[] sBuf, ref int nLen);
        [DllImport(termb_x86, EntryPoint = "GetFPR2_ReserveA2", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern bool GetFPR2_ReserveA32([MarshalAs(UnmanagedType.LPArray)]byte[] sBuf, ref int nLen);
        [DllImport(termb_x86, EntryPoint = "GetFPR2_ValidStartDate2", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern bool GetFPR2_ValidStartDate32([MarshalAs(UnmanagedType.LPArray)]byte[] sBuf, ref int nLen);
        [DllImport(termb_x86, EntryPoint = "GetFPR2_ValidEndDate2", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern bool GetFPR2_ValidEndDate32([MarshalAs(UnmanagedType.LPArray)]byte[] sBuf, ref int nLen);
        [DllImport(termb_x86, EntryPoint = "GetFPR2_ENNameB2", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern bool GetFPR2_ENNameB32([MarshalAs(UnmanagedType.LPArray)]byte[] sBuf, ref int nLen);
        [DllImport(termb_x86, EntryPoint = "GetFPR2_NationCode2", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern bool GetFPR2_NationCode32([MarshalAs(UnmanagedType.LPArray)]byte[] sBuf, ref int nLen);
        [DllImport(termb_x86, EntryPoint = "GetFPR2_Nation2", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern bool GetFPR2_Nation32([MarshalAs(UnmanagedType.LPArray)]byte[] sBuf, ref int nLen);
        [DllImport(termb_x86, EntryPoint = "GetFPR2_IDType2", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern bool GetFPR2_IDType32([MarshalAs(UnmanagedType.LPArray)]byte[] sBuf, ref int nLen);
        [DllImport(termb_x86, EntryPoint = "GetFPR2_ReserveB2", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern bool GetFPR2_ReserveB32([MarshalAs(UnmanagedType.LPArray)]byte[] sBuf, ref int nLen);
        [DllImport(termb_x86, EntryPoint = "GetFPR2_Sex2", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern bool GetFPR2_Sex32([MarshalAs(UnmanagedType.LPArray)]byte[] sBuf, ref int nLen);
        [DllImport(termb_x86, EntryPoint = "GetFPR2_IDNo2", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern bool GetFPR2_IDNo32([MarshalAs(UnmanagedType.LPArray)]byte[] sBuf, ref int nLen);//身份证号
        #endregion

        #region 港澳台居民居住证
        //---------------------------------------------------------------------------
        [DllImport(termb_x86, EntryPoint = "IsGATIDCard", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern int IsGATIDCard32();//是否港澳台居民居住证

        [DllImport(termb_x86, EntryPoint = "GetGAT_Name2", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern bool GetGAT_Name32([MarshalAs(UnmanagedType.LPArray)]byte[] sBuf, ref int nLen);//姓名

        [DllImport(termb_x86, EntryPoint = "GetGAT_SEX2", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern bool GetGAT_SEX32([MarshalAs(UnmanagedType.LPArray)]byte[] sBuf, ref int nLen);//性别

        [DllImport(termb_x86, EntryPoint = "GetGAT_SEXCode2", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern bool GetGAT_SEXCode32([MarshalAs(UnmanagedType.LPArray)]byte[] sBuf, ref int nLen);//性别代码

        [DllImport(termb_x86, EntryPoint = "GetGAT_Address2", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern bool GetGAT_Address32([MarshalAs(UnmanagedType.LPArray)]byte[] sBuf, ref int nLen);//详细地址

        [DllImport(termb_x86, EntryPoint = "GetGAT_IDNo2", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern bool GetGAT_IDNo32([MarshalAs(UnmanagedType.LPArray)]byte[] sBuf, ref int nLen);//公民身份证号码

        [DllImport(termb_x86, EntryPoint = "GetGAT_IssuingAuthority2", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern bool GetGAT_IssuingAuthority32([MarshalAs(UnmanagedType.LPArray)]byte[] sBuf, ref int nLen);//签发机关

        [DllImport(termb_x86, EntryPoint = "GetGAT_ValidStartDate2", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern bool GetGAT_ValidStartDate32([MarshalAs(UnmanagedType.LPArray)]byte[] sBuf, ref int nLen);//有效起始日期

        [DllImport(termb_x86, EntryPoint = "GetGAT_ValidEndDate2", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern bool GetGAT_ValidEndDate32([MarshalAs(UnmanagedType.LPArray)]byte[] sBuf, ref int nLen);//有效截至日期

        [DllImport(termb_x86, EntryPoint = "GetGAT_PassportNo2", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern bool GetGAT_PassportNo32([MarshalAs(UnmanagedType.LPArray)]byte[] sBuf, ref int nLen);//通行证号码(

        [DllImport(termb_x86, EntryPoint = "GetGAT_IssuanceCount2", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern bool GetGAT_IssuanceCount32([MarshalAs(UnmanagedType.LPArray)]byte[] sBuf, ref int nLen);//签发次数

        [DllImport(termb_x86, EntryPoint = "GetGAT_IDType2", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        public static extern bool GetGAT_IDType32([MarshalAs(UnmanagedType.LPArray)]byte[] sBuf, ref int nLen);//证件类型标识(2B),大写字母J

        #endregion
        #endregion
    }
}
