今天搜了不少文章关于如何用vb.net动态调用标准dll,但大多是用C#些的,而且对俺这样的菜鸟来说很是复杂,后来看了“小笨的专栏”,里面介绍了一种用C#的方法,感觉很好,现经过一些改动,用vb.net实现如下:
Imports System.Runtime.InteropServices
Module Module1
'相关的API声明
Public Declare Function GetStdHandle Lib "kernel32" _
(ByVal nStdHandle As Integer) As Integer
Private Declare Auto Function LoadLibrary Lib "kernel32" _
(ByVal LibFilePath As String) As Integer
Private Declare Function GetProcAddress Lib "kernel32" _
(ByVal ModuleHandle As Integer, ByVal ProcName As String) _
As Integer
Private Declare Function FreeLibrary Lib "kernel32" _
(ByVal ModuleHandle As Integer) As Integer
Private hLib As IntPtr
Public Sub LoadMyDLL(ByVal DLLPath As [String])