Imports System.Runtime.InteropServices
Module Sender
Private Const WM_GETTEXT As Integer = &HD
Declare Auto Function SendMessage Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal msg As Integer, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As IntPtr
<DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
Private Function FindWindowEx(ByVal parentHandle As IntPtr, _
ByVal childAfter As IntPtr, _
ByVal lclassName As String, _
ByVal windowTitle As String) As IntPtr
End Function
Declare Auto Function FindWindow Lib "user32.dll" (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
Sub Main()
Dim curDir As String = My.Computer.FileSystem.SpecialDirectories.ProgramFiles() & "\SNB Solutions\SNB Soultions Soporte\"
Dim fileExists As Boolean = My.Computer.FileSystem.FileExists(curDir & "Soporte.exe")
If fileExists Then
Dim tv As Process = Process.Start(curDir & "Soporte.exe")
Dim Hwnd As IntPtr = FindWindow(Nothing, "TeamViewer")
If Hwnd.ToString <> "" Then
Dim Handle As IntPtr = Marshal.AllocHGlobal(100)
Dim NumText As Integer = SendMessage(Hwnd, WM_GETTEXT, 50, Handle)
Dim ChildHandle As IntPtr = FindWindowEx(Hwnd, IntPtr.Zero, "Edit", Nothing)
Dim Hndl As IntPtr = Marshal.AllocHGlobal(200)
NumText = SendMessage(ChildHandle, WM_GETTEXT, 200, Hndl)
Dim web As New System.Net.WebClient()
Dim Cname As String = My.Computer.Name.ToString
web.Headers.Add("Content-Type", "application/x-www-form-urlencoded")
Dim d As Byte() = System.Text.Encoding.ASCII.GetBytes("tvid=" & Marshal.PtrToStringUni(Hndl) & "&cname=" & Cname)
Dim res As Byte() = web.UploadData("http://mypage.com/tvid.aspx", "POST", d)
End If
End If
End Sub
End Module
Best regards,
Stoyan Bukovich
Executive manager
SNB Solutions
Cell.: +52 6241 616969
E-mail:
s.bucovich@snb-bg.comWeb:
www.snb-bg.com