Microsoft POS无法识别扫描仪

我有Metro Technologies的条形码扫描仪,我正在使用Microsoft POS 检测扫描仪的输入。它使用USB连接到我的系统 港口。但是POS没有识别扫描仪。
public Form1()
{
InitializeComponent();
explorer = new PosExplorer(this);
explorer.DeviceAddedEvent += new
DeviceChangedEventHandler(explorer_DeviceAddedEvent);
}


void explorer_DeviceAddedEvent(object sender, DeviceChangedEventArgs e)
{
if (e.Device.Type == "Scanner")
{
scanner = (Scanner)explorer.CreateInstance(e.Device);
scanner.Open();
scanner.Claim(1000);
scanner.DeviceEnabled = true;
scanner.DataEvent += new
DataEventHandler(activeScanner_DataEvent);
scanner.DataEventEnabled = true;
scanner.DecodeData = true;
}
}

void activeScanner_DataEvent(object sender, DataEventArgs e)
{
UpdateEventHistory("Data Event");
ASCIIEncoding encoder = new ASCIIEncoding();
try
{
// Display the ASCII encoded label text
txtbScanDataLabel.Text =
encoder.GetString(activeScanner.ScanDataLabel);
// Display the encoding type
txtbScanDataType.Text = activeScanner.ScanDataType.ToString();

// re-enable the data event for subsequent scans
activeScanner.DataEventEnabled = true;
}
catch (PosControlException)
{
// Log any errors
UpdateEventHistory("DataEvent Operation Failed");
}
}
    
已邀请:
从一些论坛和POS SDK文档: 您必须在目录中的xml文件中添加它:
C:Program FilesCommon Filesmicrosoft sharedPoint Of ServiceControl Configurations
<PointOfServiceConfig Version="1.0">
 <ServiceObject Type="Scanner" Name="Example scanner">
  <HardwareId From="HIDVID_04B4&amp;PID_0100&amp;REV_0001" To="HIDVID_04B4&amp;PID_0100&amp;REV_0001" />
 </ServiceObject>
</PointOfServiceConfig>
您必须检查设备的硬件ID并将其替换为
<HardwareId>
标签内的 这是即插即用配置。     
这是整个代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.PointOfService;
using System.Collections;

namespace MicrosoftPOSScannerSample
{
    public partial class Form1 : Form
    {
        private PosExplorer explorer;
        private Scanner scanner;

        public Form1()
        {
            InitializeComponent();
            explorer = new PosExplorer(this);
            explorer.DeviceAddedEvent += new DeviceChangedEventHandler(explorer_DeviceAddedEvent);
        }

        private void Form1_Load(object sender, EventArgs e)
        {
        }

        private void UpdateEventHistory(string newEvent)
        {
            txtbEventHistory.Text = newEvent + System.Environment.NewLine + txtbEventHistory.Text;
        }

        void explorer_DeviceAddedEvent(object sender, DeviceChangedEventArgs e)
        {
            if (e.Device.Type == "Scanner")
            {
                scanner = (Scanner)explorer.CreateInstance(e.Device);
                scanner.Open();
                scanner.Claim(1000);
                scanner.DeviceEnabled = true;
                scanner.DataEvent += new DataEventHandler(scanner_DataEvent);
                scanner.DataEventEnabled = true;
                scanner.DecodeData = true;
            }
        }

        void scanner_DataEvent(object sender, DataEventArgs e)
        {
            UpdateEventHistory("Data Event");
            ASCIIEncoding encoder = new ASCIIEncoding();
            try
            {
                // Display the ASCII encoded label text
                txtbScanDataLabel.Text = encoder.GetString(scanner.ScanDataLabel);
                // Display the encoding type
                txtbScanDataType.Text = scanner.ScanDataType.ToString();

                // re-enable the data event for subsequent scans
                scanner.DataEventEnabled = true;
            }
            catch (PosControlException)
            {
                // Log any errors
                UpdateEventHistory("DataEvent Operation Failed");
            }
        }

    }
}
    
我不熟悉您正在使用的扫描仪,但在您通常希望确保扫描仪本身配置为正确的模式/设置等之前,我已经使用过所有这些。通常,这是通过执行手册中的配置序列来完成的,您将扫描编程设备的各种条形码。 如果没有别的,你可以排除硬件配置的问题,而不是你的代码。
explorer_DeviceAddedEvent
有没有火?
scanner
在哪里  和
activeScanner
初始化? [编辑] 检查扫描仪本身或随附的文档以获取硬件ID(HID),尝试在代码中添加以下行。
[HardwareId(@"this is where the HID goes")]
看看是否能让您获得更多信息...有关详细信息,请参阅此处,您可以提供HID或在XML配置文件中添加该信息     
我在这里找到了配置(Windows 7平台):   C: Documents and Settings All Users Application Data Microsoft Point of Service Configuration Configuration.xml     

要回复问题请先登录注册