The only thing I am having trouble with is nesting the snes9x window into the panel and I feel i'm missing something very simple I have gotten the kill and launch working but not the nesting any one got any surjections or snippets of code that I could try?
Sorry the code is messy but the button2_click works and with button1_click is where I have been trying different bits of coding that I have found round the internet (well pretty much all of it is snippets from the internet)
Code: Select all
Public Class Form1
Private Const WM_SYSCOMMAND As Integer = 274
Private Const SC_MAXIMIZED As Integer = 61488
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
Public Sub KillProcess(ByVal processName As String)
On Error GoTo ErrHandler
Dim oWMI
Dim ret
Dim sService
Dim oWMIServices
Dim oWMIService
Dim oServices
Dim oService
Dim servicename
oWMI = GetObject("winmgmts:")
oServices = oWMI.InstancesOf("win32_process")
For Each oService In oServices
servicename = LCase(Trim(CStr(oService.Name) & ""))
If InStr(1, servicename, LCase(processName), vbTextCompare) > 0 Then
ret = oService.Terminate
End If
Next
oServices = Nothing
oWMI = Nothing
ErrHandler:
Err.Clear()
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
KillProcess("snes9x")
Dim proc As System.Diagnostics.Process
proc = Process.Start("C:\Users\SNES_Machine_002\Desktop\Aero the Acro-Bat (USA).sfc")
proc.WaitForInputIdle()
SetParent(proc.MainWindowHandle, Me.Panel1.Handle)
SendMessage(proc.MainWindowHandle, WM_SYSCOMMAND, SC_MAXIMIZE, 0)
End Sub
Private Sub Button2_click(sender As Object, e As EventArgs) Handles Button2.Click
KillProcess("snes9x")
Process.Start("C:\Users\SNES_Machine_002\Desktop\Aladdin (U) [!].smc")
End Sub
End Class