近來試着在 Intermec 700 上开发带有条码扫描功能的应用程序,初步得出开发时需环境如下:
1. Visual Studio 2003 軟件安裝
2. Microsoft ActiveSync 4.5 中文版安裝,來源自己上網搜尋
3. Intermec开发环境(在Intermec官方网站上下载安装包,后安装即有对应环境,且还有User Guide,该 User Guide对入门很有帮助)
1) Data Collection Resource Kit: 读扫描条码 / SQL Ce操作
2) Device Management Resource Kit: 设备管理操作
3) Device Resource Kit: 声音设备操作
4) Bluetooth Resource Kit: 蓝牙设备操作
5) Printing Resource Kit: 打印设备操作
6) Communications Resource Kit: 通讯设备操作
4. 开发简单的扫描条码的应用程序,请参考Data Collection Resource Kit User Guide的 Net Class Guides的 Using the barcodeReader Class 下的说明及案例
5. 自编程序如下:
1) 实现功能:在Text 框中显示當前扫描到的条码,在 ListBox 框中顯示所有的條碼
2) 在 vs 2003中需引用 Intermec Data Collection dll 文件
3) 編寫 Code 如下
using System;
using System.Drawing;
using System.Collections;
using System.Windows.Forms;
using System.Data;
namespace SmartDeviceApplication2
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
//定义接收barcode的对象
private Intermec.DataCollection.BarcodeReader MyReaderData = null;
//显示扫描到的barcode(当前)
private System.Windows.Forms.TextBox txtScan;
//显示扫描到的barcode(历史)
private System.Windows.Forms.ListBox ReaderDataListBox;
//退出按钮
private System.Windows.Forms.Button Back;
private System.Windows.Forms.Label label1;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.txtScan = new System.Windows.Forms.TextBox();
this.ReaderDataListBox = new System.Windows.Forms.ListBox();
this.Back = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
//
// txtScan
//
this.txtScan.Location = new System.Drawing.Point(16, 30);
this.txtScan.Size = new System.Drawing.Size(192, 21);
this.txtScan.Text = "txtScan";
//
// ReaderDataListBox
//
this.ReaderDataListBox.Location = new System.Drawing.Point(16, 56);
this.ReaderDataListBox.Size = new System.Drawing.Size(192, 182);
//
// Back
//
this.Back.Location = new System.Drawing.Point(112, 248);
this.Back.Text = "Back";
this.Back.Click += new System.EventHandler(this.Back_Click);
//
// label1
//
this.label1.Font = new System.Drawing.Font("SimSun", 12F, System.Drawing.FontStyle.Regular);
this.label1.Location = new System.Drawing.Point(16, 8);
this.label1.Text = "Scanning";
//
// Form1
//
this.Controls.Add(this.label1);
this.Controls.Add(this.Back);
this.Controls.Add(this.ReaderDataListBox);
this.Controls.Add(this.txtScan);
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.Closed += new System.EventHandler(this.Form1_Closed);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
static void Main()
{
Application.Run(new Form1());
}
private void Form1_Load(object sender, System.EventArgs e)
{
//取得barcodeReader句柄
MyReaderData = new Intermec.DataCollection.BarcodeReader();
// Create event handler delegate
MyReaderData.BarcodeRead += new Intermec.DataCollection.BarcodeReadEventHandler(MyReader_ReadNotify);
//This method tells BarcodeReader to start reading and to fire an event when a bar code is read.
MyReaderData.ThreadedRead(true); //本语句必须存在,否则将无法触发 MyReader_ReadNotify 过程
}
private void MyReader_ReadNotify(object sender, Intermec.DataCollection.BarcodeReadEventArgs e)
{
//显示当前 扫描到的barcode
txtScan.Text = e.strDataBuffer;
//将当前扫描到的barcode 写到历史barcode中
ReaderDataListBox.Items.Add(e.strDataBuffer);
}
private void Back_Click(object sender, System.EventArgs e)
{
//关闭程序
this.Close();
}
private void Form1_Closed(object sender, System.EventArgs e)
{
//停止扫描
Stop_Scan();
}
public void Stop_Scan()
{
// If you have a scanner
if(MyReaderData != null)
{
MyReaderData.BarcodeRead -= new Intermec.DataCollection.BarcodeReadEventHandler(MyReader_ReadNotify);
// Free it up
MyReaderData.Dispose();
// Indicate you no longer have a scanner
MyReaderData = null;
}
}
}
}