Communicate between two Visual Basic Applications

How to communicate between 2 different visual basic applications.

Simple technique by using SendMessage()

	'Main app that tries to communicate with other
	Public Class Form1
		'Project App1

		Private Const APP2_MSG1 As Integer = 6541

		Declare Auto Function SendMessage Lib "user32.dll" _
		(ByVal hWnd As IntPtr, ByVal Msg As Integer, _
		 ByVal wParam As Integer, ByVal lParam As Integer) As Integer

		Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
		Handles Button1.Click
			Dim p() As Process = Process.GetProcessesByName("App2")
			If p.Count > 0 Then
				Dim hWnd As IntPtr = p(0).MainWindowHandle
				SendMessage(hWnd, APP2_MSG1, 0, 0)
				Debug.WriteLine("Msg sent")
			End If
		End Sub
	End Class

Read more to get code of Listening application

Continue reading