示例#1
0
        private void button1_Click(object sender, EventArgs e)
        {
            LoadPOSDll PosPrint = new LoadPOSDll();

            //POS_COM_DTR_DSR 0x00 流控制为DTR/DST
            //POS_COM_RTS_CTS 0x01 流控制为RTS/CTS
            //POS_COM_XON_XOFF 0x02 流控制为XON/OFF
            //POS_COM_NO_HANDSHAKE 0x03 无握手
            //POS_OPEN_PARALLEL_PORT 0x12 打开并口通讯端口
            //POS_OPEN_BYUSB_PORT 0x13 打开USB通讯端口
            //POS_OPEN_PRINTNAME 0X14 打开打印机驱动程序
            //POS_OPEN_NETPORT 0x15 打开网络接口

            if (PosPrint.OpenNetPort("192.168.0.123"))//当参数nParam的值为POS_OPEN_NETPORT时,表示打开指定的网络接口,如“192.168.10.251”表示网络接口IP地址,打印时参考
            {
                Gp_IntPtr = PosPrint.POS_IntPtr;
            }
            if (LoadPOSDll.POS_StartDoc())
            {
                byte[] by_SendData = System.Text.Encoding.Default.GetBytes("test print\r\n");
                LoadPOSDll.POS_WriteFile(PosPrint.POS_IntPtr, by_SendData, (uint)by_SendData.Length);
                LoadPOSDll.POS_WriteFile(PosPrint.POS_IntPtr, new byte[] { 0x0a }, 1);
                LoadPOSDll.POS_EndDoc();
            }
        }
示例#2
0
        public static void NetworkPrinter(Printer p, string[] contents)
        {
            Console.WriteLine("网口测试");
            LoadPOSDll PosPrint = new LoadPOSDll();

            //POS_COM_DTR_DSR 0x00 流控制为DTR/DST
            //POS_COM_RTS_CTS 0x01 流控制为RTS/CTS
            //POS_COM_XON_XOFF 0x02 流控制为XON/OFF
            //POS_COM_NO_HANDSHAKE 0x03 无握手
            //POS_OPEN_PARALLEL_PORT 0x12 打开并口通讯端口
            //POS_OPEN_BYUSB_PORT 0x13 打开USB通讯端口
            //POS_OPEN_PRINTNAME 0X14 打开打印机驱动程序
            //POS_OPEN_NETPORT 0x15 打开网络接口

            if (PosPrint.OpenNetPort("192.168.1.124"))//当参数nParam的值为POS_OPEN_NETPORT时,表示打开指定的网络接口,如“192.168.10.251”表示网络接口IP地址,打印时参考
            {
                //驱动打印句柄
                IntPtr Gp_IntPtr = PosPrint.POS_IntPtr;
            }
            if (LoadPOSDll.POS_StartDoc())
            {
                string strs = "";
                for (int i = 0; i < contents.Length; i++)
                {
                    strs = strs + contents[i] + "\n";
                }
                byte[] by_SendData = System.Text.Encoding.Default.GetBytes(strs);
                LoadPOSDll.POS_WriteFile(PosPrint.POS_IntPtr, by_SendData, (uint)by_SendData.Length);
                LoadPOSDll.POS_WriteFile(PosPrint.POS_IntPtr, new byte[] { 0x0a }, 1);
                LoadPOSDll.POS_CutPaper(1, 1);
                LoadPOSDll.POS_EndDoc();
            }
        }