
分享到
新浪微博

分享到
朋友圈

分享到
QQ空間
發布日期:2020-09-24 來源: 本站 閱讀量(3172)
urovo優博訊手持終端PDA wince系統手持機開發必須使用真機開發試調 關于如何優博訊winCE手持終端/優博訊V5000S手持機進行二次開發,主要是優博訊的掃描頭調用可以參考下面的代碼: using System; using System.Collections.Generic; using System.Text; using System.Threading; namespace Urovo { public class DecodeEventArgs : EventArgs { private string barcode; private byte type; public DecodeEventArgs(string barcodeData, byte typeData) { barcode = barcodeData; type = typeData; } public string Barcode { get { return barcode; } set { barcode = value; } } public byte Type { get { return type; } set { type = value; } } } class Scanner { public event EventHandler<DecodeEventArgs> DecodeEvent; private bool needClose = false; private IntPtr[] hEvent = new IntPtr[2]; private IntPtr hNotify = IntPtr.Zero; private Thread scanThread; private bool isContinuousMode; public bool IsContinuousMode { get { return isContinuousMode; } set { isContinuousMode = value; } } public bool Start() { if (Device.SCA_GetPowerStatus() == 0) { Device.SCA_EnableModule(); needClose = true; } Win32.MSGQUEUEOPTIONS options = new Win32.MSGQUEUEOPTIONS(); options.dwSize = 20; options.dwFlags = 2; options.dwMaxMessages = 3; options.cbMaxMessage = 252; options.bReadAccess = true; IntPtr hMsgQ = Win32.CreateMsgQueue(null, options); if (hMsgQ == IntPtr.Zero) { return false; } hNotify = Device.SCA_RegisterNotification(hMsgQ); if (hNotify == IntPtr.Zero) { return false; } hEvent[0] = Win32.CreateEvent(IntPtr.Zero, false, false, null); hEvent[1] = hMsgQ; scanThread = new Thread(new ThreadStart(this.ScanThreadPorc)); scanThread.Start(); return true; } public void Stop() { try { Win32.EventModify(hEvent[0], Win32.EVENT_SET); if (!scanThread.Join(3000)) { scanThread.Abort(); } } catch (Exception ex) { } Win32.CloseHandle(hEvent[0]); Device.SCA_UnRegisterNotification(hNotify); Win32.CloseHandle(hEvent[1]); if (needClose) { Device.SCA_DisableModule(); } else if (isContinuousMode) { Device.SCA_SetTriggerMode(Device.TriggerMode.Normal); } } public bool SwitchTriggerMode() { if (isContinuousMode) { if (Device.SCA_SetTriggerMode(Device.TriggerMode.Normal)) { isContinuousMode = false; return true; } } else { if (Device.SCA_SetTriggerMode(Device.TriggerMode.Continuous)) { isContinuousMode = true; return true; } } return false; } private void ScanThreadPorc() { while (true) { uint evt = Win32.WaitForMultipleObjects(2, hEvent, false, Win32.INFINITE); switch (evt) { case 0://return thread return; case 1://disable network uint bytesRead; uint flags; byte[] buf = new byte[256]; if (Win32.ReadMsgQueue(hEvent[1], buf, 256, out bytesRead, Win32.INFINITE, out flags)) { EventHandler<DecodeEventArgs> temp = DecodeEvent; if (temp != null) { temp(this, new DecodeEventArgs(Encoding.Default.GetString(buf, 2, (int)bytesRead), buf[1])); } } break; } } } } } 具體的可以找PDA導購網索要對應的開發包,獲取優博訊手持終端的開發支持庫,開發演示例子。 優博訊安卓手持終端售后電話咨詢技術支持,歡迎咨詢PDA導購網! 商米安卓手持收銀機POS安卓、商米單屏/雙屏幕臺式收銀機、安卓自助收銀機,歡迎咨詢PDA導購網 PDA導購網(www.vtgvip.com)專業的條碼手持終端、工業級PDA、RFID手持機,防爆PDA選型導購網站! 選型條碼手持終端、盤點機,RFID手持終端,安卓PDA,防暴手持機,請聯系PDA導購網免費給您推薦最合適的手持終端! 聯系方式:柳工 手機(微信同號):15016095220 備注:PDA導購網