Private Declare Function SendMessageByString Lib "user32.dll" Alias "SendMessageA" _
(ByVal hwnd As IntPtr, _
ByVal uMsg As Int32, _
ByVal wParam As IntPtr, _
ByVal lParam As String) As Integer
Private Const WM_SETTEXT As Int32 = &HC
Private Declare Function SendMessageByInt Lib "user32.dll" Alias "SendMessageA" _
(ByVal hwnd As IntPtr, _
ByVal uMsg As Int32, _
ByVal wParam As Int32, _
ByVal lParam As Int32) As Integer
Private Const WM_GETTEXTLENGTH As Int32 = &HE
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As IntPtr
Private Declare Function FindWindowEx Lib "user32.dll" Alias "FindWindowExA" _
(ByVal hWnd1 As IntPtr, _
ByVal hWnd2 As IntPtr, _
ByVal lpsz1 As String, _
ByVal lpsz2 As String) As IntPtr
Public Function GetHandle(ByVal ClassName As String) As IntPtr
Dim hwnd As IntPtr = FindWindow(ClassName, Nothing)
hwnd = FindWindowEx(hwnd, IntPtr.Zero, "Edit", Nothing)
If (Not hwnd.Equals(IntPtr.Zero)) Then
Return hwnd
Else
Return IntPtr.Zero
End If
End Function
Public Sub SetNewText(ByVal hwnd As IntPtr, ByVal txt As String)
If (Not hwnd.Equals(IntPtr.Zero)) Then
Call SendMessageByString(hwnd, WM_SETTEXT, IntPtr.Zero, txt)
End If
End Sub