日期:2014-05-17 浏览次数:21219 次
/// <summary> /// 北洋OPOS指令集二次开发包DLL调用 /// public class BeiYangOPOS { const string _DllVer = "1.4"; /// <summary> /// 获取动态库版本号 /// </summary> public string GetDllVer { get { return _DllVer; } } /// <summary> /// 设备打开后的句柄 /// </summary> public IntPtr POS_IntPtr; //打开打印机 [DllImport("POSDLL.dll", CharSet = CharSet.Ansi)] public static extern IntPtr POS_Open([MarshalAs(UnmanagedType.LPStr)]string lpName,uint nComBaudrate,uint nComDataBits,uint nComStopBits,uint nComParity,uint nParam); //关闭打印机 [DllImport("POSDLL.dll", SetLastError = true)] public static extern IntPtr POS_Close(); //输出文本 [DllImport("POSDLL.dll", SetLastError = true)] public static extern IntPtr POS_S_TextOut([MarshalAs(UnmanagedType.LPStr)]string pszString,uint nOrgx, uint nWidthTimes, uint nHeightTimes,uint nFontType, uint nFontStyle); }
foreach (KeyValuePair<string, PosPrinter> pos in poss) //循环所有打印机 { pos.Value.Work(); //执行打印机任务 }
public void Work() { Thread worker = new Thread(new ThreadStart(PrintWork)); worker.Start(); } public void PrintWork() { string err = string.Empty; opos.OpenNetPort(ip); foreach (string Work in Works) { BeiYangOPOS.POS_S_TextOut(Work, 0, 1, 2, opos.POS_FONT_TYPE_STANDARD, opos.POS_FONT_STYLE_NORMAL); BeiYangOPOS.POS_S_TextOut(this.ip, 0, 1, 3, opos.POS_FONT_TYPE_STANDARD, opos.POS_FONT_STYLE_NORMAL); BeiYangOPOS.POS_FeedLine(); BeiYangOPOS.POS_FeedLine(); BeiYangOPOS.POS_FeedLine(); BeiYangOPOS.POS_FeedLine(); BeiYangOPOS.POS_FeedLine(); BeiYangOPOS.POS_CutPaper(0, 200); BeiYangOPOS.POS_FeedLine(); BeiYangOPOS.POS_FeedLine(); } opos.ClosePrinterPort();