c#读条码程序 |
您所在的位置:网站首页 › vericode官网 › c#读条码程序 |
其实,条形码读取器就相当于键盘(I/O)设备,只要设置输入焦点,扫描枪扫描一下就能够显示出数据来!
protected Intermec.DataCollection.BarcodeReader gScanner;public Scan(){InitializeComponent();}#region Intermec 扫描处理 #region 启动Intermec扫描protected void OpenScanner(){if (Common.exceptionFlag == "0"){Application.DoEvents();if (gScanner != null){return;}try{gScanner = new BarcodeReader();gScanner.BarcodeRead += new BarcodeReadEventHandler(Scanner_BarcodeRead);gScanner.ThreadedRead(true); }catch (System.Exception){MessageBox.Show("您的设备不支持扫描不能进行清查操作,只具有查看设备信息功能!", Common.messageCaption); Common.exceptionFlag = "1";}}} //关闭扫描protected void CloseScanner(){if (Common.exceptionFlag == "0"){try{Application.DoEvents();if (gScanner != null){gScanner.BarcodeRead -= new BarcodeReadEventHandler(Scanner_BarcodeRead);gScanner.Dispose();gScanner = null;//GC.Collect(); }}catch (System.Exception){MessageBox.Show("您的设备不支持扫描不能进行清查操作,只具有查看设备信息功能!", Common.messageCaption); Common.exceptionFlag = "1";}}}#endregion #region 定义Intermec扫描事件protected void Scanner_BarcodeRead(object sender, BarcodeReadEventArgs bre){ string dabh = bre.strDataBuffer; } |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |