I want to run an app inside a panel or something within my applicaiton. It's an emulator front end. You browse through games, then when you select one it launches the emulator. I found the following code and adapted it to my project
Public Class Form1
Declare Auto Function SetParent Lib "user32.dll" (ByVal hWndChild As IntPtr, ByVal hWndNewParent As IntPtr) As Integer
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 Const WM_SYSCOMMAND As Integer = 274
Private Const SC_MAXIMIZE As Integer = 61488
Dim proc As Process
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
proc = Process.Start("C:WINDOWS
otepad.exe")
proc.WaitForInputIdle()
SetParent(proc.MainWindowHandle, Panel1.Handle)
SendMessage(proc.MainWindowHandle, WM_SYSCOMMAND, SC_MAXIMIZE, 0)
End Sub
End Class
If I try it with notepad, or even zsnesw.exe it works okay, but if I try to pass some parameters to zsnesw it kind of freaks out and I have to reboot my computer (I can't switch applications or even open the task manager).
Also, even when it does work, the start menu pops up like I have switched to another app. This is kind of what I was trying to avoid in the first place as my app is full screen.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…