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中的参数怎么定义的呀,我网上找了半天也没一个看的懂的说 展开
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中的参数怎么定义的呀,我网上找了半天也没一个看的懂的说 展开
展开全部
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
改为
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
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询