0

我正在使用 .Net 开发计费应用程序。我需要使用 EPSON TM-T81 打印收据。我已经安装了所有必需的驱动程序和 MS POS v1.12。我可以通过 CheckHealth Utility 成功打印示例内容。所以看起来 PosPrinter 配置没有问题。但仍然 PosExplorer().getDevices 返回空值。我在 Windows 和 ASP.Net 应用程序中都尝试过,但仍然是同样的问题。代码:PosPrinter m_Printer = null;

        //<<<step1>>>--Start
        //Use a Logical Device Name which has been set on the SetupPOS.
        string strLogicalName = "PosPrinter";
        try
        {
            //Create PosExplorer
            PosExplorer posExplorer = new PosExplorer();

            DeviceInfo deviceInfo = null;

            try
            {
                deviceInfo = posExplorer.GetDevice(DeviceType.PosPrinter,strLogicalName);
                m_Printer =(PosPrinter)posExplorer.CreateInstance(deviceInfo);
            }
            catch(Exception)
            {
                ChangeButtonStatus();
                return;
            }

            //Open the device
            m_Printer.Open();

            //Get the exclusive control right for the opened device.
            //Then the device is disable from other application.
            m_Printer.Claim(1000);

            //Enable the device.
            m_Printer.DeviceEnabled = true;
        }
        catch(PosControlException)
        {
            ChangeButtonStatus();
        }
        //<<<step1>>>--End
4

1 回答 1

0

如果这正是您要运行的代码,那么问题在于 strLogicalName 不包含有效的 SO 或逻辑设备名称。“PosPrinter”只是代码示例中的一个占位符(当然,除非您明确设置这样的逻辑名称)。

为了找出系统中可用的 SO 名称/逻辑设备名称,请使用以下命令:

"C:\Program Files (x86)\Microsoft Point Of Service\posdm.exe" listdevices /type:PosPrinter

"C:\Program Files (x86)\Microsoft Point Of Service\posdm.exe" listnames /type:PosPrinter
于 2015-04-16T13:28:08.690 回答