I have two applications
the first one programmed using C
the second with VB.NET
i want to Execute the first one and keep status updated to the second
is there a way to do that ?
i can change the source code of any one of them
OK, in VB you need to implement an interface between the two programs so you can pass parameters between them.
In program1 (the calling program) I set this up:
Dim oType As System.Type
Dim oAssembly As System.Reflection.Assembly
Dim oObject As System.Object
oAssembly = Reflection.Assembly.LoadFrom("C:\VB.NET\report3.exe")
oType = oAssembly.GetType("report3.r1") ' this is [root_namespace.class name]
oObject = Activator.CreateInstance(oType)
oObject.SetParams("a", "b")
oObject.show()
This causes report3.exe to run and sends it the "a" and "b" parameters as values.
Then in program2 (report3.exe), I set it up like this:
Imports System.Reflection
Public Class r1
Implements IPlugin
Public person As String = ""
Public address As String = ""
Private Sub r1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Me.TopMost = True 'optional
Dim b1 As New Label()
With b1
.Location = New Point(10, 10)
.Width = 200
.Height = 20
.Parent = Me
.BackColor = Color.Blue
.ForeColor = Color.White
.Text = person
End With
call_addr()
End Sub
Public Sub SetParams(c As String, d As String) Implements IPlugin.SetParams
person = c
address = d
End Sub
Private Sub call_addr()
Dim b2 As New Label()
With b2
.Location = New Point(10, 50)
.Width = 200
.Height = 20
.Parent = Me
.BackColor = Color.Red
.text = address
End With
End Sub
End Class
Public Interface IPlugin
Sub SetParams(ByVal c As String, ByVal d As String)
End Interface