Salve a tutti, io ho un palmare con Windows Mobile 6.5 con lettore di codice a barre integrato ed è quello che mi interessa, vorrei utilizzare i dati letti senza entrare in emulazione tastiera.
La casa produttrice (Symbol/Motorola) ha messo a disposizione delle librerie per farlo ed ho sviluppato il codice sia in VB.NET che in C#, ma nessuno dei due funziona perchè mi dice che non può attivare il reader qualcuno saprebbe aiutarmi?
codice:
VB.NET
Imports Symbol
Imports Symbol.Barcode
Public Class Form1
Private MyScanner As Symbol.Barcode.Device = Nothing
Private MyReader As Symbol.Barcode.Reader = Nothing
Private MyReaderData As Symbol.Barcode.ReaderData = Nothing
Private MyEventHandler As System.EventHandler = Nothing
Private Sub MyReader_ReadNotify(ByVal o As Object, ByVal e As EventArgs)
MsgBox(MyReaderData.Text, "HelloScan")
MyReader.Actions.Read(MyReaderData)
End Sub
Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
MyReader.Actions.Flush()
MyReader.Actions.Disable()
MyReader.Actions.Dispose()
MyReaderData.Dispose()
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
MyScanner = Symbol.Barcode.Device.AvailableDevices.First
MyReader = New Symbol.Barcode.Reader(MyScanner)
MyReaderData = New Symbol.Barcode.ReaderData(Symbol.Barcode.ReaderDataTypes.Text, Symbol.Barcode.ReaderDataLengths.DefaultText)
MyEventHandler = New System.EventHandler(AddressOf MyReader_ReadNotify)
AddHandler MyReader.ReadNotify, Me.MyEventHandler
MyReader.Actions.Enable()
MyReader.Actions.Read(MyReaderData)
End Sub
End Class
C#
using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Symbol;
using Symbol.Barcode;
namespace c_barcode
{
public partial class Form1 : Form
{
//setup Reader & ReaderData objects
Symbol.Barcode.Reader barcodeReader = null;
Symbol.Barcode.ReaderData barcodeReaderData = null;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
barcodeReader = new Symbol.Barcode.Reader();
//sets up ReaderData to receive text and allocates max buffer size for barcode (7905 bytes).
barcodeReaderData = new Symbol.Barcode.ReaderData(Symbol.Barcode.ReaderDataTypes.Text,
Symbol.Barcode.ReaderDataLengths.MaximumLabel);
barcodeReader.Actions.Enable(); //enable scanner hardware.
barcodeReader.Actions.Read(barcodeReaderData); //read scan.
barcodeReader.ReadNotify += new EventHandler(barcodeReader_Read); //eventHandler for when read is complete.
}
private void barcodeReader_Read(object sender, EventArgs e)
{
Symbol.Barcode.ReaderData nextReaderData = barcodeReader.GetNextReaderData(); //Get(s)NextReaderData
MessageBox.Show(nextReaderData.Text); //Display output in messagebox.
barcodeReader.Actions.Read(barcodeReaderData); //await next scan.
}
private void Form1_Closing(object sender, CancelEventArgs e)
{
//Dispose of everything
barcodeReader.Actions.Flush();
barcodeReader.Actions.Disable();
barcodeReader.Dispose();
barcodeReaderData.Dispose();
}
}
}