VB.Net打开新表单实例作为单独的进程

时间:2013-04-24 20:48:03

标签: vb.net pid toolstripmenu

我正在尝试使用新的进程ID启动我的应用程序的单独实例。有没有办法做到这一点?以下代码将显示单独的表单,但它共享原始表单的进程ID:

Private Sub NewToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles NewToolStripMenuItem.Click
    Dim SecondForm As New MyForm()
    SecondForm.Show()
End Sub

当用户从工具条菜单中选择“新建”选项时,我基本上想要复制与打开应用程序相同的行为。

1 个答案:

答案 0 :(得分:0)

我找到了解决方案。

Private Sub NewToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles NewToolStripMenuItem.Click        
    Dim ExePath As String = Application.ExecutablePath
    Process.Start(ExePath)
End Sub