VB-调用Dll里面的方法
一个简单的调用DLL里面的方法,首先引用DLL进项目,然后根据下面方法进行调用。
Dim objType As System.Type = Nothing
Dim objAssembly As System.Reflection.Assembly
Dim objMethod As System.Reflection.MethodInfo = Nothing
Dim objReturn As Object = Nothing
Dim objArgs As Object() = Nothing
objAssembly = System.Reflection.Assembly.UnsafeLoadFrom("DLL路径")
objType = objAssembly.GetType("命名空间")
objMethod = objType.GetMethod("方法名称")
objArgs = New Object() {"传递的参数,必须与传入方法的参数一致"}
objReturn = objMethod.Invoke(Nothing, objArgs)