首页 > Windows开发 > 详细

调用wince扫描机红外扫描

时间:2015-04-16 17:16:16      阅读:213      评论:0      收藏:0      [点我收藏+]
public class CLR_Barcode_1D
    {
        [DllImport("DeviceAPI.dll",EntryPoint="Barcode1D_init")]
        private static extern bool Barcode1D_init();

        [DllImport("DeviceAPI.dll", EntryPoint = "Barcode1D_scan")]
        private static extern int Barcode1D_scan(byte[] pszData);

        [DllImport("DeviceAPI.dll", EntryPoint = "Barcode1D_free")]
        private static extern void Barcode1D_free();

        public static bool Scan(out string barcode)
        {
            Barcode1D_init();
            byte[] pszData = new byte[64];
            int iRes = Barcode1D_scan(pszData);
            Barcode1D_free();
            if (iRes > 0)
            {
                barcode = System.Text.Encoding.GetEncoding(0).GetString(pszData, 0, iRes).Trim();
                if (barcode.Length > 0)
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
            else
            {
                barcode = string.Empty;
                return false;
            }
        }
    }

调用

string barcode;
                bool result = CLR_Barcode_1D.Scan(out barcode);
                this.txtBarcode.Text = barcode;//扫描结果
                if (result)
                {
                    //TODO
                }

 

调用wince扫描机红外扫描

原文:http://www.cnblogs.com/DonnyPeng/p/4432551.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!