今年做了几台PDA,型号都不太一样,不过调用的它们的扫描头都是大同小异(需要厂家提供SDK),在此记录下最近用到的一个PDA的扫描
java和c#大体上差不多,在某个方面上有点不同,在运用“:”和LINQ,契约式编程(只运用过数据契约)感受比较多,另外kotlin虽然兼容java,能支持所有java库,但写起来差别也挺多的,不过在调用继承和接口倒是和c#相同(小白看法)
好像PDA(window ce和window mobile 6)只能在vs2008运用。首先引入了几个需要用到的dll,每个厂家的sdk都有所不同(同个厂家可能型号不同也有不同的SDK),所以需要让厂家提供或者官网找(度娘也可以)
这是欣技PDA9700要用到的dll
不多说,直接上代码
using System;
using System.Device9700;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DeviceInterface;
namespace Divce9700Project
{
public partial class Form1 : Form
{
private PDADevice mPDADevice;
public Form1()
{
InitializeComponent();
}
/// <summary>
/// 初始化
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Form1_Load(object sender, EventArgs e)
{
mPDADevice = new PDADevice();
openScan();
mPDADevice.SetScanMode(TriggerMode.Normal);//TriggerMode.Continuous
}
/// <summary>
/// 开启扫描
/// </summary>
private void openScan()
{
mPDADevice.ScannerStartScan();
mPDADevice.OnScannerEvent += new EventHandler<ScanEventArgs>(mScanner_DataArrivedEvent);
}
/// <summary>
/// 关闭扫描
/// </summary>
private void closeScan()
{
mPDADevice.ScannerStopScan();
mPDADevice.OnScannerEvent -= new EventHandler<ScanEventArgs>(mScanner_DataArrivedEvent);
}
/// <summary>
/// 条码扫描触发事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void mScanner_DataArrivedEvent(object sender, ScanEventArgs e)
{
try
{
String code = e.Barcode;//获取条码
label1.Text =code;
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
/// <summary>
/// 结束
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Frmscan_closed(object sender, EventArgs e)
{
closeScan();
this.Close();
}
}
}
这样就能调用该PDA的扫描头的扫描了
我是源码 (附有接口调用文档)