随笔 - 435  文章 - 0  评论 - 111  阅读 - 62万 

硬件: EPSON TMH6000M

软件: EPSON OPOS ADK 2.5

        Microsoft POS for .net 1.12

 

step 1.

 EPSON OPOS ADK 2.5 是pos打印机的驱动的集合. 安装后接上pos打印机,

开始菜单里面有一个setup pos的工具, 添加pos打印机,选择合适的端口, 安装完成要给该pos打印机起一个LogicalName,供程序使用

 

step 2

 安装Microsoft POS for .net 1.12, 这个是微软对POS设备的封装层.只要是符合国际标准的设备都能识别使用.

 

step 3

     .net代码 引用 Microsoft.PointOfService

  示例代码:

 如果要打印中文(簡體/繁體), 則要留意Printer的CharacterSetList有沒有包含936,950,

另外要注意window區域設置的non-unicode的設定是否一致.例如你要打繁體的話,就必須設置成中國香港(950)

            

复制代码
代码
 1 //Use a Logical Device Name which has been set on the SetupPOS.
 2             string strLogicalName = "PosPrinter";
 3 
 4             //Create PosExplorer
 5             PosExplorer posExplorer = new PosExplorer();
 6 
 7             DeviceInfo deviceInfo = null;
 8 
 9             try
10             {
11                 deviceInfo = posExplorer.GetDevice(DeviceType.PosPrinter, strLogicalName);
12 
13       m_Printer = (PosPrinter)posExplorer.CreateInstance(deviceInfo);
14                 //Open the device
15                 m_Printer.Open();
16 
17                 //Get the exclusive control right for the opened device.
18                 //Then the device is disable from other application.
19                 m_Printer.Claim(1000);
20 
21                //Enable the device.
22                 m_Printer.DeviceEnabled = true;
23 
24       m_Printer.PrintNormal(PrinterStation.Receipt, "Hello World!\n"); 
25 
26            }
27             catch (Exception)
28             {
29 
30             }
31 
32 
复制代码

 

 

   

 

 

posted on   Gu  阅读(1268)  评论(1编辑  收藏  举报
编辑推荐:
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· 什么是nginx的强缓存和协商缓存
· 一文读懂知识蒸馏
· Manus爆火,是硬核还是营销?
点击右上角即可分享
微信分享提示