Exp=x
ModuleFileName=Function_1.vb
@end
                                        
Imports System.Runtime.InteropServices
Imports System.Text
Public Class @ytclass

     '//´칤Զɣѡ--ܼģ顱
    '//¶˶ClientKeyDll̬ĵ
     <DllImport("ClientKeyDll.dll", CharSet:=CharSet.Ansi)> Public Shared Function FindPort_2(ByVal start As Int32, ByVal filename As String, ByVal pos As Integer, ByVal OutPath As StringBuilder) As Integer
    End Function
    <DllImport("ClientKeyDll.dll", CharSet:=CharSet.Ansi)> Public Shared Function FindPort_3(ByVal filename As String, ByVal pos As Integer, ByVal OutPath As StringBuilder) As Integer
    End Function
    <DllImport("ClientKeyDll.dll", CharSet:=CharSet.Ansi)> Public Shared Function FindPort_4(ByVal filename As String, ByVal pos As Integer, ByVal HKey As String, ByVal LKey As String, ByVal OutPath As StringBuilder) As Integer
    End Function
    <DllImport("ClientKeyDll.dll", CharSet:=CharSet.Ansi)> Public Shared Function Cal_2(ByVal filename As String, ByVal start As Integer, ByVal vlen As Integer, ByRef ele1 As Byte, ByRef ele2 As Byte, ByRef ele3 As Byte, ByRef ele4 As Byte, ByVal KeyPah As String, ByVal cycle As Integer) As Integer
    End Function
    <DllImport("ClientKeyDll.dll", CharSet:=CharSet.Ansi)> Public Shared Function GetIDVersionEx(ByRef ID As Integer, ByRef version As Integer, ByVal KeyPah As String) As Integer
    End Function
    <DllImport("ClientKeyDll.dll", CharSet:=CharSet.Ansi)> Public Shared Function GetVersion_2(ByRef VersionEx As Integer, ByVal KeyPah As String) As Integer
    End Function
    <DllImport("ClientKeyDll.dll", CharSet:=CharSet.Ansi)> Public Shared Function YReadEx(ByVal Address As Integer, ByRef OutData As Byte, ByVal KeyPah As String) As Integer
    End Function
    <DllImport("ClientKeyDll.dll", CharSet:=CharSet.Ansi)> Public Shared Function YWriteEx(ByVal InData As Byte, ByVal Address As Integer, ByVal KeyPah As String) As Integer
    End Function
    <DllImport("ClientKeyDll.dll", CharSet:=CharSet.Ansi)> Public Shared Function ReadString(ByVal OutString As String, ByVal Address As Integer, ByVal vlen As Integer, ByVal KeyPah As String) As Integer
    End Function
    <DllImport("ClientKeyDll.dll", CharSet:=CharSet.Ansi)> Public Shared Function WriteString(ByVal InString As String, ByVal Address As Integer, ByVal KeyPah As String) As Integer
    End Function
    <DllImport("ClientKeyDll.dll", CharSet:=CharSet.Ansi)> Public Shared Function FindPort(ByVal pos As Integer, ByVal OutPath As StringBuilder) As Integer
    End Function
    <DllImport("ClientKeyDll.dll", CharSet:=CharSet.Ansi)> Public Shared Function E_Dec_6(ByVal HKey As String, ByVal LKey As String, ByVal array_ele2() As Byte, ByVal out_array() As Byte, ByVal KeyPah As String) As Integer
    End Function
    <DllImport("ClientKeyDll.dll", CharSet:=CharSet.Ansi)> Public Shared Function CalculateEx_2(ByVal array_ele() As Byte, ByRef ele1 As Byte, ByRef ele2 As Byte, _
                            ByRef ele3 As Byte, ByRef ele4 As Byte, ByVal KeyPah As String, ByVal mylen As Integer, ByVal cycle As Integer) As Integer
    End Function
    <DllImport("ClientKeyDll.dll", CharSet:=CharSet.Ansi)> Public Shared Function E_Ex_3(ByVal HKey As String, ByVal LKey As String, ByVal filename As String, ByVal filename_lll As String, ByVal KeyPath As String) As Integer
    End Function
    <DllImport("ClientKeyDll.dll", CharSet:=CharSet.Ansi)> Public Shared Function CalculateEx_3(ByVal filename As String, ByVal start As Integer, ByVal pos As Integer, ByRef A As Byte, ByRef B As Byte, _
                            ByRef C As Byte, ByRef D As Byte, ByVal KeyPah As String, ByVal cycle As Integer) As Integer
    End Function
        <DllImport("ClientKeyDll.dll", CharSet:=CharSet.Ansi)> Public Shared Function ConnectServer(ByVal servername As String, ByVal port As Integer) As Integer
    End Function
    <DllImport("ClientKeyDll.dll", CharSet:=CharSet.Ansi)> Public Shared Function DisconnectServer() As Integer
    End Function
	<DllImport("ClientKeyDll.dll", CharSet:=CharSet.Ansi)> Public Shared sub AutoDisConnect(ByVal m_timer As Integer, ByVal biao As boolean)
    End Sub
    Dim LastError As Long 'Ĵ
    Dim KeyPath As String
    
     'ServerConnect
    'Ŀģӷ
    '1servername ҪӵķƻIPַ
    '2port Ӷ˿,˿ںſԶ
    'ؽ0ʾɹӷʾʧ
    'ע⣺ʹκκ֮ǰһҪȵøúini֮ǰڳ˳ʱмһҪʹDisConnectServerϿ
    Public Function ServerConnect(ByVal servername As String, ByVal port As Integer) As Integer
        Dim ret As Integer
        ret = ConnectServer(servername, port)
        If ret <> 0 Then
            MsgBox("ӷ򣬴Ϊ" + Str(ret))
        End If
        AutoDisConnect(60000, True) 'ڳʱԶϿЧӣʱʱΪ60
        Return ret
    End Function

    'ServerDisConnect
    'ĿģϿ
    'ؽ0ʾɹϿʾʧ
    'ע⣺ڳ˳ʱмһҪʹDisConnectServerϿ
    Public Function ServerDisConnect() As Integer
        Return DisconnectServer()
    End Function

    'YGetID
    'ĿģؼID
    'ؽؼID
    Public Function YGetID() As Integer
        Dim m_Version As Integer
        Dim m_id As Integer
        LastError = GetIDVersionEx(m_id, m_Version, KeyPath)
        Return m_id
    End Function
    
    '//ºڽֽתΪַ
    Public Function ByteConvertString(ByVal buffer() As Byte) As String
        Dim null_string() As Char = {Chr(0), Chr(0)}
        Dim encoding As System.Text.Encoding = System.Text.Encoding.Default
        ByteConvertString = encoding.GetString(buffer).TrimEnd(null_string)
    End Function
    '//ºڽַתΪֽ
    Public Function StringConvertByte(ByVal buffer() As Byte, ByVal InS As String) As Boolean
        Try
            Dim n As Integer
            Dim temp() As Byte = System.Text.Encoding.Default.GetBytes(InS)
            If temp.Length > 50 Then Return False
            For n = 1 To temp.Length
                buffer(n - 1) = temp(n - 1)
            Next n
        Catch
            Return True
        End Try
        Return True
    End Function
 

    Public Sub New()
        LastError = 0 'ʼΪ޴
    End Sub

    Protected Overrides Sub Finalize()
        MyBase.Finalize()
    End Sub

	'GetLastError
	'ĿģȡĴ룬Ϊ0ʾûд
	'ؽĴ
	Public Function YGetLastError() As Long
	    YGetLastError = LastError
	End Function
	#f_Ini#
    #f_Ini_3#
	#f_Ystrcat#
	#f_YCompareString#
	#f_Ystrcpy#
	#f_YAdd#
	#f_YSetValue#
	#f_YDivide#
	#f_Ymultiply#
	#f_YDecrease#
	#f_Ycompare#
	#f_CheckKey#
	#f_YAnd#
	#f_Yor#

End Class
