【问题标题】:POS for .Net can not detect printer.Net 的 POS 无法检测到打印机
【发布时间】:2012-12-16 02:01:21
【问题描述】:

我正在为我的一个项目使用 .Net 框架版本 1.12 的 POS。

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 无法检测到打印机,而只能在我运行我的应用程序时打开带有数据的模拟器。

谁能帮帮我?

【问题讨论】:

  • 您的打印机详细信息 (LDN) 是否已添加到配置文件中??

标签: c# asp.net winforms pos-for-.net


【解决方案1】:

我为运行 Windows CE 作为操作系统的 POS 开发了一个应用程序,但对于该 POS,制造商提供了一个自定义 dll 用于调用我在 C# 代码中使用的打印机操作。请咨询 POS 制造商,看看他们是否提供了自定义 dll。

【讨论】:

    【解决方案2】:

    你的代码行

    DeviceInfo receiptPrinterDevice = posExplorer.GetDevice(DeviceType.PosPrinter);
    

    将返回找到的 defaultfirst 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 for .Net SDK 附带的 POSDM 实用程序)并将上述行更改为

    DeviceInfo receiptPrinterDevice = posExplorer.GetDevice(DeviceType.PosPrinter, "madeUpLogicalName");
    

    (3)只需将所需的打印机设置为默认打印机,然后保持您的代码不变。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-10-11
      • 1970-01-01
      • 2020-05-31
      • 2014-03-06
      • 2014-11-16
      • 1970-01-01
      • 2018-05-13
      相关资源
      最近更新 更多