首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >PosExplorer().getDevices在.Net应用程序中返回null

PosExplorer().getDevices在.Net应用程序中返回null
EN

Stack Overflow用户
提问于 2014-09-20 17:59:43
回答 1查看 1.7K关注 0票数 0

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

代码语言:javascript
复制
        //<<<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
EN

回答 1

Stack Overflow用户

发布于 2015-04-16 21:28:09

如果这正是您试图运行的代码,那么问题是strLogicalName没有包含有效的SO或逻辑设备名。"PosPrinter“在代码示例中只是一个占位符(当然,除非您显式地设置了这样一个逻辑名称)。

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

代码语言:javascript
复制
"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
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25947558

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档