无法与vb.net中的Motorola SNAPI扫描引擎通信

时间:2014-03-13 02:58:30

标签: c# vb.net barcode motorola

我有一项任务是与摩托罗拉SNAPI扫描引擎设备建立通信,作为vb.net项目。我一直在参考摩托罗拉C#中的示例源代码以及Snapi文档。设备正确响应SNAPI_Init调用,但随后无法处理以下SNAPI_Connect调用。请协助。感谢。

http://www.motorolasolutions.com/web/Business/Products/Bar%20Code%20Scanning/Bar%20Code%20Scanners/Fixed%20Mount%20Scanners/MiniScan%204400/_Documents/Static%20Files/SnapiProgrammersGuide_7137001.pdf

`
`**My vb.net code:**
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Text
Imports System.IO
Imports System.Threading
Imports System.Runtime.InteropServices
Imports System.Collections.ObjectModel
Imports System.Collections.Specialized
Imports System.Windows.Forms
Imports System
Imports Scan_2d_7mar.SnapiDLL

Public Class Form1
    'Declaration
    Dim status As Integer
    Dim xstatus As Integer
    Dim num_device As Integer
    Dim m_hWnd As Integer = Me.Handle.ToInt32
    Dim devicehandle(8) As Integer
    Dim sernum() As String
    'obtain and populate the s/n for this scanner
    Public sb As New System.Text.StringBuilder(100)

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        status = SnapiDLL.SNAPI_Init(m_hWnd, devicehandle, num_device)
        TextBox1.Text = devicehandle(0)
        TextBox2.Text = num_device
        TextBox3.Text = m_hWnd
        If ((status = 0) And num_device) Then 'Assuming one scanner found during call to SNAPI_Init
            Dim y() As Byte
            xstatus = SNAPI_GetSerialNumber(devicehandle(0), y)

            xstatus = SnapiDLL.SNAPI_Connect(devicehandle(0))
            TextBox2.Text = sb.ToString(4, sb.Length - 4)
            TextBox1.Text = xstatus
        Else
            TextBox1.Text = 9
        End If
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

    End Sub
End Class

0 个答案:

没有答案