using System; using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; namespace MeterPlugInLibrary { public class Scanning { /// /// 设置设备类型 /// [DllImport("GeitBarCodeReader.dll", EntryPoint = "SetDeviceType", CharSet = CharSet.Ansi)] public static extern int SetDeviceType(int iType); /// /// 打开扫码枪串口 /// [DllImport("GeitBarCodeReader.dll", EntryPoint = "OpenDevice", CharSet = CharSet.Ansi)] public static extern int OpenDevice(int iPort, string szComParam); /// /// 关闭扫码枪串口 /// [DllImport("GeitBarCodeReader.dll", EntryPoint = "CloseDevice", CharSet = CharSet.Ansi)] public static extern int CloseDevice(); /// /// 获取扫码枪状态 /// [DllImport("GeitBarCodeReader.dll", EntryPoint = "GetStatus", CharSet = CharSet.Ansi)] public static extern int GetStatus(); /// /// 复位 /// [DllImport("GeitBarCodeReader.dll", EntryPoint = "Reset", CharSet = CharSet.Ansi)] public static extern int Reset(); /// /// 同步读条码信息 /// [DllImport("GeitBarCodeReader.dll", EntryPoint = "ReadData", CharSet = CharSet.Ansi)] public static extern int ReadData(ref byte szData, int iTimeout); /// /// 开始异步读数据 /// [DllImport("GeitBarCodeReader.dll", EntryPoint = "BeginReadASYN", CharSet = CharSet.Ansi)] public static extern int BeginReadASYN(); //************************************************************** /// /// 停止异步读数据 /// [DllImport("GeitBarCodeReader.dll", EntryPoint = "CancelReadASYN", CharSet = CharSet.Ansi)] public static extern int CancelReadASYN(); /// /// 读取条码数据异步 /// [DllImport("GeitBarCodeReader.dll", EntryPoint = "ReadDataASYN", CharSet = CharSet.Ansi)] public static extern int ReadDataASYN(ref byte szData); //************************************************************** /// /// 获取中文错误信息 /// [DllImport("GeitBarCodeReader.dll", EntryPoint = "GetErrInfo", CharSet = CharSet.Ansi)] public static extern int GetErrInfo(ref string szErrorInfo); } }