Symbol 開發初體驗(2)

今天安裝了 vs2003 Profession English 版本,並在其中重新編寫了“HelloScan”程序。但存在“无法将程序发布到symbol mc1000 问题”,其中參數為:ActiveSync4.5 中文版、Symbol 開發包 Smdk1.07版、vc#程序中 Deployment Device=”Windows CE .Net Device”。后查詢資料發現需作如下變動:
1、建立连接的时候选择guest,也就是不要与pc同步
2、建立wince的windows应用程序,进行部署的时候先选ppc设备(这个是必须的,经测试,先选ce就不行,但先选ppc再选ce没问题)

另1:之前提到“因爲在虛擬器中,所以沒有掃描設備,故涉及到MyReader要註釋掉(如:MyReader = new Symbol.Barcode.Reader();),否則會提示“NullReferenceException 试图在代码中引用不存在的对象时””,因爲本次是在真正設備上運行,故沒有註釋 MyReader 語句。也運行正常。
另2:因手頭還有台 Intermec Scan Device,用以下程序 Deploy 到該設備,正常,但 Scan 時無法彈出 Barcode,推測結論為:Symbol的SDK 無法用在其它品牌的Code上

附 HelloScan 源程序:
using System;
using System.Drawing;
using System.Collections;
using System.Windows.Forms;
using System.Data;

namespace Mc1000_test01
{
 /// <summary>
 /// Summary description for Form1.
 /// </summary>
 public class Form1 : System.Windows.Forms.Form
 {
  private Symbol.Barcode.Reader MyReader = null;
  private Symbol.Barcode.ReaderData MyReaderData = null;

  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()
  {
   //
   // Form1
   //
   this.Text = "Form1";
   this.Closing += new System.ComponentModel.CancelEventHandler(this.Form1_Closing);
   this.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.Form1_KeyPress);
   this.Load += new System.EventHandler(this.Form1_Load);

  }
  #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)
  {
   //System.Windows.Forms.MessageBox.Show("xxxxxx", "HelloScan");

   MyReader = new Symbol.Barcode.Reader();
   MyReaderData =
    new Symbol.Barcode.ReaderData(Symbol.Barcode.ReaderDataTypes.Text,
    Symbol.Barcode.ReaderDataLengths.DefaultText);
   MyReader.ReadNotify += new EventHandler(MyReader_ReadNotify);
   MyReader.Actions.Enable();
   MyReader.Actions.Read (MyReaderData);
   return;
  }

  private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
  {
   MyReader.Actions.Flush();
   MyReader.Actions.Disable();
   MyReader.Dispose();
   MyReaderData.Dispose();
   return;
  }
  private void MyReader_ReadNotify(object sender, EventArgs e)
  {
   //System.Windows.Forms.MessageBox.Show("yyyyyy", "HelloScan");
   System.Windows.Forms.MessageBox.Show(MyReaderData.Text, "HelloScan");
   MyReader.Actions.Read(MyReaderData);
   return;
  }

  private void Form1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
  {
   if (e.KeyChar==(char)13)
   {
    MyReader.Actions.Flush();
    MyReader.Actions.Disable();
    MyReader.Dispose();
    MyReaderData.Dispose();
    this.Close();
   }    
  }  
 }
}

你可能感兴趣的:(ol)