vb.net中SendMessager的问题 20

PublicClassForm1PrivateDeclareAutoFunctionFindWindowLib"user32"(ByVallpClassNameAsStr... Public Class Form1
Private Declare Auto Function FindWindow Lib "user32" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
Private Declare Function FindWindowEx Lib "user32.dll" Alias "FindWindowExA" (ByVal hWnd1 As Int32, ByVal hWnd2 As Int32, ByVal lpsz1 As String, ByVal lpsz2 As String) As Int32
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As String, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long
Private Const WM_SETTEXT = &HC
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Call GetWindowTitle()
End Sub
Private Sub GetWindowTitle()
Dim hWnd As Integer
Dim RichEdit As String
hWnd = FindWindow("Notepad", "无标题 - 记事本")
MsgBox(hWnd)
RichEdit = FindWindowEx(hWnd, 0, "Edit", vbNullString)
MsgBox(RichEdit)
SendMessage(RichEdit, WM_SETTEXT, 0, "hhhhhhhh")
End Sub
End Class

这个程序中最后的那个SendMessage老是出错,不知道什么问题呀,本人初学,那个SendMessage中的参数怎么定义的呀,我网上找了半天也没一个看的懂的说
展开
 我来答
百度网友32cdd9945
2007-01-12 · TA获得超过1374个赞
知道大有可为答主
回答量:2429
采纳率:100%
帮助的人:1932万
展开全部
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As String, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long

改为

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As String, ByVal wMsg As integer, ByVal wParam As integer , ByVal lParam As String) As integer

再试试,
可能你的声明使用vb6。0 复制过来的,long 全部改成integer
ABC08008
2007-01-26 · 超过27用户采纳过TA的回答
知道答主
回答量:84
采纳率:0%
帮助的人:0
展开全部
很不正常!
VB6自带了这个函数,为什么要去申明API!
这个函数的用法:
SendMessage 要发送的字符串
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式