VB.NET调用Windows API函数 方法 (实例)

前端之家收集整理的这篇文章主要介绍了VB.NET调用Windows API函数 方法 (实例)前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

本例是Form中有一个按钮。

点击按钮,Form的Title会显示指定的文字

Public Class Form3


Private Declare Auto Function SendMessage Lib "user32" Alias "SendMessageW" (ByVal hwnd As Integer,ByVal wMsg As Integer,ByVal wParam As Integer,ByVal lParam As String) As Integer

Private Const EM_SETTEXT = &HC ' VB中&H表示16进制
'Private Const WM_GETTEXT = &HC

Private Sub Button1_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles Button1.Click

Dim hwnd As IntPtr = CType(Me.Handle,IntPtr)

'Sendmessage(目标控件句柄,自定义消息类型,参数个数,消息内容)
SendMessage(hwnd,EM_SETTEXT,"myTest")

End Sub

End Class

原文链接:https://www.f2er.com/vb/259783.html

猜你在找的VB相关文章