我正在为我的一个项目使用POS1.12版本的.Net框架。
Microsoft POS for .NET是一个类库,是Microsoft Windows Embedded for Point of Service的一部分。http://msdn.microsoft.com/en-us/library/ms828083%28v=winembedded.10%29.aspx
private PosPrinter GetReceiptPrinter()
{
PosExplorer posExplorer = new PosExplorer(this);
DeviceInfo receiptPrinterDevice = posExplorer.GetDevice(DeviceType.PosPrinter);
return (PosPrinter)posExplorer.CreateInstance(receiptPrinterDevice);
}
上面是查找打印机的示例代码。现在我的问题是,当我运行应用程序时,POS无法检测到打印机,而只能打开包含数据的模拟器。
有谁能帮帮我吗?
发布于 2013-01-01 11:02:38
我已经为运行Windows CE操作系统的POS机开发了一个应用程序,但是对于那个POS机,制造商提供了一个自定义的dll来调用我在C#代码中使用的打印机操作。请与POS制造商联系,看看他们是否提供相同的自定义dll。
发布于 2013-12-13 01:39:15
您的代码行
DeviceInfo receiptPrinterDevice = posExplorer.GetDevice(DeviceType.PosPrinter);
将返回找到的默认或first PosPrinter,在您的示例中,它看起来就像是模拟器。
您需要对打印机集合进行(1)迭代,然后以某种方式选择您想要的打印机。即
foreach (DeviceInfo deviceInfo in explorer.GetDevices(DeviceType.PosPrinter))
{
if (isThisThePrinterIWant(deviceInfo)) // user defined function (maybe lookup saved preference file)
{
return (PosPrinter)posExplorer.CreateInstance(deviceInfo );
}
} // Note: GetDevices() not GetDevice()
或者(2)为您的打印机设置一个逻辑名称(使用您的打印机附带的软件或Pos .Net SDK附带的POSDM实用程序),然后将上面的行更改为
DeviceInfo receiptPrinterDevice = posExplorer.GetDevice(DeviceType.PosPrinter, "madeUpLogicalName");
或者(3)只需将所需的打印机设置为默认打印机,并让代码保持原样。
https://stackoverflow.com/questions/14109583
复制