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");
}
}
Please see post reply in forum at:
http://social.msdn.microsoft.com/Forums/en-US/posfordotnet/thread/0305a26
0-8e3a-4b83-aabe-a4f4c117f0dd
--
This posting is provided "As Is" with no warranties, and confers no rights.
X-Face: 3bv|Grp$j"BCYpET|y@@/5=;j9@Zuc[XSbP7Ui8#`J0J|PX0c!m9=]McR9PPq
\TvMOAvJUes)hkN;<}cLH#}@F~*t`[>9@,;4`@OEs?BpPKrJ+x.E{1i.AEbJ6ul-~X/1
6Hqa0bJ4m]?L@j?dy.l_=|b[iZjr>!x:P_&p"[OI@^'^-U[^6FHdTI5~"Ak[Vp%?ba?/
CcQZS+nKY[D!H~08:[_F8^I{%c#yh8;#u7$m0^dZ3DOr=6=!*`"(z3%$HUBVFlfAn4H0
\<f:HYfWP:g<P:3gp?6d,ge~y
Make sure you have the Service Object installed (and configured if
needed). Also, make sure the scanner is configured to work under UPOS.
By default some scanners may be configured as keyboard devices out of
the box and need to be reconfigured.