关于SetWindowText和 GetWindowText的用法,折腾了好久了!还是没解决,请教大家看下哪里出问题了
Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim hWnd As Integer
Shell("C:\WINDOWS\system32\calc.exe", AppWinStyle.NormalFocus)
hWnd = FindWindow(vbNullString, "计算器")
Dim strText As String
strText = Space(30)
If hWnd Then
GetWindowText(hWnd, strText, 30)
MessageBox.Show(strText, "获取标题") 'strtext 没有显示出标题名称
SetWindowText(hWnd, "修改内容") '标题未修改成 “修改内容”,为空
End If
End Sub