USB接口ID卡读卡器oem软件/读写卡测试程序及源代码/VB.net源代码

 

 

详细代码如下:(如有疑问可13826029618进行相关提问解答,或荣士电子页面查询)

 

Public Class Form1
    Inherits System.Windows.Forms.Form

'广州荣士电子,定制13826029618 网址http://www.icmcu.com


#Region " Windows 窗体设计器生成的代码 "

    Public Sub New()
        MyBase.New()

        '该调用是 Windows 窗体设计器所必需的。
        InitializeComponent()

        '在 InitializeComponent() 调用之后添加任何初始化

    End Sub

    '窗体重写 dispose 以清理组件列表。
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Windows 窗体设计器所必需的
    Private components As System.ComponentModel.IContainer

    '注意: 以下过程是 Windows 窗体设计器所必需的
    '可以使用 Windows 窗体设计器修改此过程。
    '不要使用代码编辑器修改它。
    Friend WithEvents Button1 As System.Windows.Forms.Button
    Friend WithEvents Button2 As System.Windows.Forms.Button
    Friend WithEvents Button3 As System.Windows.Forms.Button
    Friend WithEvents Button4 As System.Windows.Forms.Button
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents Label3 As System.Windows.Forms.Label
    Private Sub InitializeComponent()
        Me.Button1 = New System.Windows.Forms.Button
        Me.Button2 = New System.Windows.Forms.Button
        Me.Button3 = New System.Windows.Forms.Button
        Me.Button4 = New System.Windows.Forms.Button
        Me.Label1 = New System.Windows.Forms.Label
        Me.Label2 = New System.Windows.Forms.Label
        Me.Label3 = New System.Windows.Forms.Label
        Me.SuspendLayout()
        '
        'Button1
        '
        Me.Button1.Location = New System.Drawing.Point(8, 24)
        Me.Button1.Name = "Button1"
        Me.Button1.Size = New System.Drawing.Size(168, 32)
        Me.Button1.TabIndex = 0
        Me.Button1.Text = "轻松读卡"
        '
        'Button2
        '
        Me.Button2.Location = New System.Drawing.Point(184, 24)
        Me.Button2.Name = "Button2"
        Me.Button2.Size = New System.Drawing.Size(344, 32)
        Me.Button2.TabIndex = 1
        Me.Button2.Text = "仅读一次,重新取放卡才能读到第二次"
        '
        'Button3
        '
        Me.Button3.Location = New System.Drawing.Point(184, 80)
        Me.Button3.Name = "Button3"
        Me.Button3.Size = New System.Drawing.Size(344, 32)
        Me.Button3.TabIndex = 2
        Me.Button3.Text = "读出设备全球唯一的设备编号,作为加密狗用"
        '
        'Button4
        '
        Me.Button4.Location = New System.Drawing.Point(8, 80)
        Me.Button4.Name = "Button4"
        Me.Button4.Size = New System.Drawing.Size(168, 32)
        Me.Button4.TabIndex = 3
        Me.Button4.Text = "让设备发出声响"
        '
        'Label1
        '
        Me.Label1.Location = New System.Drawing.Point(16, 128)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(504, 24)
        Me.Label1.TabIndex = 4
        Me.Label1.Text = "建议将OUR_IDR.dll和IDUSB.DLL复制到应用程序同一目录下"
        '
        'Label2
        '
        Me.Label2.Location = New System.Drawing.Point(16, 160)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(512, 24)
        Me.Label2.TabIndex = 5
        Me.Label2.Text = "每个按钮只调用到一个函数,以上3个函数可以轻松应付各类应用,可以节省大量的开发时间"
        '
        'Label3
        '
        Me.Label3.Location = New System.Drawing.Point(200, 192)
        Me.Label3.Name = "Label3"
        Me.Label3.Size = New System.Drawing.Size(192, 24)
        Me.Label3.TabIndex = 6
        Me.Label3.Text = "读卡器例子程序"
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.ClientSize = New System.Drawing.Size(536, 238)
        Me.Controls.Add(Me.Label3)
        Me.Controls.Add(Me.Label2)
        Me.Controls.Add(Me.Label1)
        Me.Controls.Add(Me.Button4)
        Me.Controls.Add(Me.Button3)
        Me.Controls.Add(Me.Button2)
        Me.Controls.Add(Me.Button1)
        Me.Name = "Form1"
        Me.Text = "Form1"
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim status As Byte

        Dim mypiccserial(4) As Byte '卡序列号

        status = idr_read(mypiccserial(0))

        If status = 0 Then
            MsgBox("操作成功卡号为" + Convert.ToString(mypiccserial(1) * 256 * 256 * 256 + mypiccserial(2) * 256 * 256 + mypiccserial(3) * 256 + mypiccserial(4)))
        ElseIf status = 8 Then
            MsgBox("请将卡放在感应区")
        ElseIf status = 23 Then
            MsgBox("机器没连上,或驱动程序未安装!")
        Else

            MsgBox("异常")

        End If

    End Sub

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

        Dim mypiccserial(4) As Byte '卡序列号

        status = idr_read_once(mypiccserial(0))

        If status = 0 Then
            MsgBox("操作成功卡号为" + Convert.ToString(mypiccserial(1) * 256 * 256 * 256 + mypiccserial(2) * 256 * 256 + mypiccserial(3) * 256 + mypiccserial(4)))
        ElseIf status = 8 Then
            MsgBox("请将卡放在感应区")
        ElseIf status = 23 Then
            MsgBox("机器没连上,或驱动程序未安装!")
        Else

            MsgBox("异常")

        End If
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        idr_beep(50)
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        '读取设备编号,可做为软件加密狗用,也可以根据此编号在公司网站上查询保修期限

        '技术支持:
        '网站:
        Dim status As Byte '存放返回值
        Dim devno(3) As Byte '设备编号

        status = pcdgetdevicenumber(devno(0))

        If status = 0 Then
            MsgBox(CStr(devno(0)) + "-" + CStr(devno(1)) + "-" + CStr(devno(2)) + "-" + CStr(devno(3)))
        End If

    End Sub
End Class

你可能感兴趣的:(读卡器IT,源代码)