Structure LoginInfo
Dim UN As String '显示的用户名 '仅为兼容第一代,如不兼容可无此项目
Dim UID As String 'User ID '仅为兼容第一代,如不兼容可无此项目
Dim SID As String 'Session ID '仅为兼容第一代,如不兼容可无此项目
Dim OtherInfo As String '其他信息 '仅为兼容第一代,如不兼容可无此项目
Dim Client_identifier As String '仅为兼容第一代,如不兼容可无此项目
Dim Suc As Boolean '登陆是否成功
Dim Errinfo As String '失败错误信息
Dim OutInfo As String '第二代输出信息
End Structure
Function GetFun(FunName As String, DLLPath As String) As Object()
Dim a As Reflection.Assembly
Dim obj As Object = Nothing
Dim m As System.Reflection.MethodInfo = Nothing
a = Reflection.Assembly.LoadFile(DLLPath)
For Each classtemp As Type In a.GetTypes
Dim t As String
t = classtemp.FullName
Dim strs() As String
strs = t.Split(".")
If classtemp.GetMethod(FunName) <> Nothing Then
m = classtemp.GetMethod(FunName)
obj = a.CreateInstance(classtemp.FullName)
End If
Next
If m Is Nothing Then
Return {"0"}
End If
Return {m, obj}
End Function
Function GetVer(DLLpath As String) As String
Dim obj1 As Object()
Dim m As System.Reflection.MethodInfo
obj1 = GetFun("GetVersion", "t:\yggdrasil.dll")
If obj1.Length = 1 Then
Return "1"
Else
m = obj1(0)
Return m.Invoke(obj1(1), {2})
End If
End Function
Function GetName(DLLpath As String) As String
Dim a As Reflection.Assembly
Dim obj As Object = Nothing
Dim m As System.Reflection.MethodInfo = Nothing
a = Reflection.Assembly.LoadFile(DLLpath)
For Each classtemp As Type In a.GetTypes
Dim t As String
t = classtemp.FullName
Dim strs() As String
strs = t.Split(".")
If classtemp.GetMethod("GetName") <> Nothing Then
m = classtemp.GetMethod("GetName")
obj = a.CreateInstance(classtemp.FullName)
End If
Next
Return m.Invoke(obj, {"zh-cn"})
End Function
Function DLLLogin(DLLpath As String, username As String, password As String, Optional Client_identifier As String = "", Optional Lanauge As String = "zh-cn") As LoginInfo
Dim a As Reflection.Assembly
Dim obj As Object = Nothing
Dim LoginInfo As Object
Dim m As System.Reflection.MethodInfo = Nothing
Dim LI As LoginInfo
a = Reflection.Assembly.LoadFile(DLLpath)
For Each classtemp As Type In a.GetTypes
Dim str As String
str = classtemp.FullName
Dim strs() As String
strs = str.Split(".")
If InStr(strs(UBound(strs)), "+logininfo", CompareMethod.Text) > 0 Then
LoginInfo = a.CreateInstance(classtemp.FullName)
End If
If classtemp.GetMethod("Login") <> Nothing Then
m = classtemp.GetMethod("Login")
obj = a.CreateInstance(classtemp.FullName)
End If
Next
LoginInfo = m.Invoke(obj, {username, password, Client_identifier, Lanauge})
Dim ww As Type
ww = LoginInfo.GetType
LI.Suc = ww.GetField("Suc").GetValue(LoginInfo)
If LI.Suc Then
LI.UN = ww.GetField("UN").GetValue(LoginInfo)
LI.UID = ww.GetField("UID").GetValue(LoginInfo)
LI.SID = ww.GetField("SID").GetValue(LoginInfo)
LI.OtherInfo = ww.GetField("OtherInfo").GetValue(LoginInfo)
LI.Client_identifier = ww.GetField("Client_identifier").GetValue(LoginInfo)
Else
LI.Errinfo = ww.GetField("Errinfo").GetValue(LoginInfo)
End If
Return LI
End Function
|