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) 

posted @ 2014-10-23 12:53  小陈同学  阅读(1114)  评论(0编辑  收藏  举报