PDA并不神秘,或者很简单
基恩士官网文档:https://www.keyence.com.cn/support/user/bt/download/btw/index.jsp
基恩士 做的很好的地方就是在开发上 给了我们十分详细的文档说明,从而可以顺利的搭建好开发环境。
1,我们需要做的事情 其实很简单,要先拿到 基恩士 提供给我们的dll文件,如下所示:(至于这些dll的作用,那你需要慢慢去看文档了)
2, 然后我们需要 去 基恩士官网下载 ( https://www.keyence.com.cn/support/user/bt/download/btw/index.jsp )一个文件,如下。我们主要看这个文件就好了,它会一步步带我们 搭建好 开发环境。
3, 具体代码如下所示: (主要作用 是 比对两次扫描结果是否相同。)
下面的代码中就用到了基恩士的sdk,然而这样子程序运行起来之后,基恩士自己的扫描键会失灵。 所以尽量少用SDK .
using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.IO;
using Bt.ScanLib;
using Bt;
namespace keyencePDA1
{
public partial class Form1 : Form
{
// 消息窗口
MsgWindow MsgWin;
// 窗体
public static Form1 _MainForm1Instance;
// 应用执行路径
public static String AppPath = "";
public static string FirstBarCode=string.Empty;
public static string SecondBarCode = string.Empty;
public static Int32 ScanCount = 0;
public Form1()
{
InitializeComponent();
// 生成消息窗口
}
[DllImport("coredll.dll", EntryPoint = "DeleteObject")]
public static extern bool DeleteObject(IntPtr hObject);
private void Form1_Load(object sender, EventArgs e)
{
// 画面尺寸调整
if (System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width == 240)
{
resolution.ScreenSize.VGAtoQVGA(this);
}
// 不显示窗体的最大化,最小化按钮
this.MaximizeBox = !this.MaximizeBox;
this.MinimizeBox = !this.MinimizeBox;
_MainForm1Instance = this;
// 取得执行路径
String path = this.GetType().Assembly.GetModules()[0].FullyQualifiedName;
Int32 en = path.LastIndexOf("\\");
AppPath = path.Substring(0, en);
}
private void Form1_Closed(object sender, EventArgs e)
{
if (Form1._MainForm1Instance != null)
{
Form1._MainForm1Instance.Dispose();
}
}
//扫描按钮点击
private void button1_Click(object sender, EventArgs e)
{
this.MsgWin = new MsgWindow();
Int32 ret = 0;
String disp = "";
try
{
//开启扫描
ret = Bt.ScanLib.Control.btScanEnable();
if (ret != LibDef.BT_OK)
{
disp = "btScanEnable error ret[" + ret + "]";
//MessageBox.Show(disp, "错误");
ScanCopmareInit(