日期:2014-05-18 浏览次数:20921 次
//DLL中的函数声明 //app传入 //buffer 传出 ISO8583DLL_API int Pack_Ex (application* app,unsigned char * buffer );
//机构体定义 [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] internal struct Application_Ex { public static Application_Ex InitShuZu() { Application_Ex obj = new Application_Ex(); obj.process_code = new byte[5]; obj.trans_type = new byte[3]; obj.park_id = new byte[PARK_ID_LENGTH + 1]; obj.terminal_id = new byte[TERMINAL_ID_LENGTH + 1]; //............. //内容太多,没有贴完 } // package public byte[] source_tpdu ; public byte[] target_tpdu ; public byte itrans_type; public byte[] trans_type ; //............. //内容太多,没有贴完 } //DLL函数导出 [DllImport("ISO8583Dll.dll", EntryPoint = "Pack_Ex")] private static extern int Pack_Ex(Application_Ex app_ex, byte[] buff); //函数调用 unsafe public static void jgtdy() { Application_Ex m_txd = new Application_Ex(); m_txd = Application_Ex.InitShuZu(); try { //赋值 m_txd.process_code[0] = (byte)'0'; m_txd.process_code[1] = (byte)'0'; m_txd.process_code[2] = (byte)'0'; m_txd.process_code[3] = (byte)'6'; m_txd.trans_type[0] = (byte)'8'; m_txd.trans_type[1] = (byte)'1'; //010101009001 m_txd.park_id[0] = (byte)'0'; m_txd.park_id[1] = (byte)'1'; m_txd.park_id[2] = (byte)'0'; m_txd.park_id[3] = (byte)'1'; m_txd.park_id[4] = (byte)'0'; m_txd.park_id[5] = (byte)'1'; m_txd.park_id[6] = (byte)'0'; m_txd.park_id[7] = (byte)'0'; m_txd.park_id[8] = (byte)'9'; m_txd.park_id[9] = (byte)'0'; m_txd.park_id[10] = (byte)'0'; m_txd.park_id[11] = (byte)'1'; //02010001 m_txd.terminal_id[0] = (byte)'0'; m_txd.terminal_id[1] = (byte)'2'; m_txd.terminal_id[2] = (byte)'0'; m_txd.terminal_id[3] = (byte)'1'; m_txd.terminal_id[4] = (byte)'0'; m_txd.terminal_id[5] = (byte)'0'; m_txd.terminal_id[6] = (byte)'0'; m_txd.terminal_id[7] = (byte)'1'; //20120420 m_txd.trans_date[0] = (byte)'2'; m_txd.trans_date[1] = (byte)'0'; m_txd.trans_date[2] = (byte)'1'; m_txd.trans_date[3] = (byte)'2'; m_txd.trans_date[4] = (byte)'0'; m_txd.trans_date[5] = (byte)'4'; m_txd.trans_date[6] = (byte)'2'; m_txd.trans_date[7] = (byte)'0'; //005006 m_txd.trans_time[0] = (byte)'0'; m_txd.trans_time[1] = (byte)'0'; m_txd.trans_time[2] = (byte)'5'; m_txd.trans_time[3] = (byte)'0'; m_txd.trans_time[4] = (byte)'0'; m_txd.trans_time[5] = (byte)'6'; //000100 m_txd.lsh = 000100; m_txd.host_lsh = 000000000000; //000101 m_txd.batch_no = 000101; m_txd.amount = 000000000000; //0033 m_txd.para_ver = 0033;