硬件: 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
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