Public Class Form1
    Private Declare Sub getDiskSerialNumber1 Lib "jydisk" (ByVal drive As Byte, ByRef pout As Byte, ByRef poutsize As Integer, ByVal PNPDeviceID As Boolean)
    Private Declare Sub doReg Lib "jydisk" (ByVal userid As Byte(), ByVal useridsize As Integer, ByVal regid As Byte(), ByVal regidsize As Integer)
    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Dim sResult(200) As Byte
        Dim il As Integer
        Dim c As String
        '分配100个字节空间
        'sResult = String(200, " ")
        il = 0
        'id = 0
        c = Microsoft.VisualBasic.Left(TextBox1.Text, 1)
        Call getDiskSerialNumber1(Asc(c), sResult(0), il, False)
        Dim diskid As String


        diskid = System.Text.Encoding.ASCII.GetString(sResult)

        TextBox2.Text = CStr(il) + ":" + Trim(diskid)
        '
    End Sub

    Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
        Dim userid As String
        Dim regid As String
        Dim useridsize As Integer
        Dim regidsize As Integer
        Dim puserid As Byte()
        Dim pregid As Byte()
        'userid = "jydiskdll|qqxxx"
        userid = TextBox3.Text
        puserid = System.Text.Encoding.ASCII.GetBytes(userid)
        useridsize = userid.Length
        regid = TextBox4.Text
        pregid = System.Text.Encoding.ASCII.GetBytes(regid)
        regidsize = regid.Length
        Call doReg(puserid, useridsize, pregid, regidsize)
    End Sub
End Class
