码迷,mamicode.com
首页 > Windows程序 > 详细

调用wince扫描机红外扫描

时间:2015-04-16 17:19:11      阅读:203      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!