我有两个申请 第一个用C编程 第二个用VB.NET
我想执行第一个并保持状态更新到第二个
有办法吗?
我可以更改其中任何一个的源代码
答案 0 :(得分:0)
我可以看到使用C和VB有并发症,但这里是一个开始的地方 http://msdn.microsoft.com/en-us/library/aa365574%28VS.85%29.aspx
答案 1 :(得分:0)
好的,在VB中你需要在两个程序之间实现一个接口,这样你就可以在它们之间传递参数。
在program1(调用程序)中我设置了它:
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()
这会导致report3.exe运行并将“a”和“b”参数作为值发送给它。
然后在program2(report3.exe)中,我将其设置为:
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