【发布时间】:2020-11-06 13:43:29
【问题描述】:
我已经能够使用以下代码运行外部程序。
Imports System.Runtime.InteropServices
Public Class Form1
<DllImport("user32.dll")> Public Shared Function SetParent(ByVal hwndChild As IntPtr, ByVal hwndNewParent As IntPtr) As Integer
End Function
Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles Button1.Click
Dim PRO As Process = New Process
PRO.StartInfo.FileName = ("notepad.exe")
PRO.Start()
Do Until PRO.WaitForInputIdle = True
'Nothing
Loop
SetParent(PRO.MainWindowHandle, Me.Handle)
PRO.Dispose()
End Sub
这很好用.....(对于记事本来说)
但是,如果我为自己的 vb.net 应用程序切换记事本,它将无法在表单内启动该应用程序,而是在表单外运行它。我认为我尝试启动的应用程序可能有一些东西,所以我创建了一个没有任何内容的新应用程序(尽可能裸露)并运行它而不是记事本,但它也无法在其“父”表单,而是在“父”表单之外触发?
有人可以帮我解决这个问题吗?
【问题讨论】: