I have a barcode scanner from Metro Technologies and I am using Microsoft POS to detect the input from the scanner. It is connected to my system using USB port. But the scanner is not getting identified by the 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");
}
}