分享到
新浪微博
分享到
朋友圈
分享到
QQ空间
发布日期:2020-09-24 来源: 本站 阅读量(17329)
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.pdadaogou.com)专业的条码手持终端、工业级PDA、RFID手持机,防爆PDA选型导购网站! 选型条码手持终端、盘点机,RFID手持终端,安卓PDA,防暴手持机,请联系PDA导购网免费给您推荐最合适的手持终端! 联系方式:柳工 手机(微信同号):15016095220 备注:PDA导购网