vb.net 动态调用api
2020-12-13 05:21
标签:des style blog color io for re c vb.net 动态调用api,搜素材,soscw.com vb.net 动态调用api 标签:des style blog color io for re c 原文地址:http://www.cnblogs.com/nanfei/p/3865407.htmlImports System
Imports System.Runtime.InteropServices
Public Class DllInvoke
Public Sub New(ByVal DLLPath As String)
Me.hLib = DllInvoke.LoadLibrary(DLLPath)
End Sub
Protected Overrides Sub Finalize()
Try
DllInvoke.FreeLibrary(Me.hLib)
Finally
MyBase.Finalize()
End Try
End Sub
Imports System
Imports System.Runtime.CompilerServices
Imports System.Runtime.InteropServices
Imports System.Text
Public Class test
Private Declare Function MessageBoxA Lib "user32" Alias "MessageBoxA" (ByVal hwnd As Integer, ByVal lpText As StringBuilder, ByVal lpCaption As StringBuilder, ByVal wType As Integer) As Long
Private Delegate Function MessageBoxADelegate(ByVal hwnd As Integer, ByVal lpText As StringBuilder, ByVal lpCaption As StringBuilder, ByVal wType As Integer) As Long
Public Shared Sub Main()
Dim invoke As New DllInvoke("user32.dll")
Dim mode As MessageBoxADelegate = DirectCast(invoke.Invoke("MessageBoxA", GetType(MessageBoxADelegate)), MessageBoxADelegate)
mode.Invoke(0, New StringBuilder("haha"), New StringBuilder("title"), 0)
Console.WriteLine("ok")
Console.ReadLine()
End Sub
End Class
上一篇:css的img移上去边框效果
下一篇:子窗体中如何调用父窗体里的方法