danke für den Tipp, Lukas.
Ich hab daraufhin folgenden link gefunden:
http://www.pinvoke.net/default.aspx/user32.findwindow
darin sind 3 WinApi Funktionen angeführt:
DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
Private Shared Function FindWindow( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) As IntPtr
End Function
<DllImport("user32.dll", EntryPoint:="FindWindow", SetLastError:=True, _
CharSet:=CharSet.Auto)> _
Private Shared Function FindWindowByClass( _
ByVal lpClassName As String, _
ByVal zero As IntPtr) As IntPtr
End Function
<DllImport("user32.dll", EntryPoint:="FindWindow", SetLastError:=True, _
CharSet:=CharSet.Auto)> _
Private Shared Function FindWindowByCaption( _
ByVal zero As IntPtr, _
ByVal lpWindowName As String) As IntPtr
End Function So, nun weiß ich nicht genau, welche ich wie aufrufe.
Ich habs mal s versucht, aber ich bekomm immer eine 0 als Handle zurück:
Private Sub SetApplicationAsChild(ByVal CallingApplication As String, ByVal p _
As System.Windows.Forms.Panel)
Dim hndle As New IntPtr(0)
' Fehlerbehandlung einschalten.
Try
' Process starten ( ... film.exe ... ).
Dim hProcess As System.Diagnostics.Process = _
System.Diagnostics.Process.Start(CallingApplication)
' Siehe (... WaitForInputIdle ...)
hProcess.WaitForInputIdle()
' Parent Fenster setzen.
'Win32Api.SetParent(hProcess.MainWindowHandle, p.Handle)
hndle = Win32Api.FindWindowByClass(CallingApplication, Nothing)
Label1.Text = hndle.ToString
Win32Api.SetParent(hProcess.MainWindowHandle, hndle)
'Fenster anzeigen.
Win32Api.ShowWindow(hProcess.MainWindowHandle, Win32Api.SW_MAXIMIZE)
Catch ex As Exception
' Fehlerbeschreibung bei auftretenden Fehler anzeigen.
MessageBox.Show(ex.Message.ToString(), "Fehler beim Starten des" & _
"Demos")
End Try
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles Button2.Click
Dim p As New Process()
Const APP_NAME As String = "C:\Programme\ALLCapture 3.0" & _
"Testversion\Projekte\hardware.exe"
SetApplicationAsChild(APP_NAME, Panel1)
'p.StartInfo.FileName = APP_NAME
'p.StartInfo.WindowStyle = ProcessWindowStyle.Normal
'p.Start()
'p.WaitForExit()
'p.Close()
'MessageBox.Show("Programm wurde geschlossen")
End Sub Kannst du mir hier vielleicht etwas unter die Arme greifen?
Vielen Dank im Voraus.
Alois |