VB 6.0: Process beenden (nicht eigener)

Hallo,

Wie kann ich unter VB 6.0 einen beliebigen Process beenden? Ich stelle mir so etwas vor wie der Taskmanager.

Danke für die Hilfe

Gruss
Marc

Hi,
aus dem API-Guide:

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Long, ByVal lpWindowName As Long) As Long
Private Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Private Declare Function LockWindowUpdate Lib "user32" (ByVal hwndLock As Long) As Long
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function DestroyWindow Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
Private Declare Function GetCurrentProcess Lib "kernel32" () As Long
Private Declare Function Putfocus Lib "user32" Alias "SetFocus" (ByVal hwnd As Long) As Long
Const GW\_HWNDNEXT = 2
Dim mWnd As Long
Function InstanceToWnd(ByVal target\_pid As Long) As Long
 Dim test\_hwnd As Long, test\_pid As Long, test\_thread\_id As Long
 'Find the first window
 test\_hwnd = FindWindow(ByVal 0&, ByVal 0&amp:wink:
 Do While test\_hwnd 0
 'Check if the window isn't a child
 If GetParent(test\_hwnd) = 0 Then
 'Get the window's thread
 test\_thread\_id = GetWindowThreadProcessId(test\_hwnd, test\_pid)
 If test\_pid = target\_pid Then
 InstanceToWnd = test\_hwnd
 Exit Do
 End If
 End If
 'retrieve the next window
 test\_hwnd = GetWindow(test\_hwnd, GW\_HWNDNEXT)
 Loop
End Function
Private Sub Form\_Load()
 'KPD-Team 1999
 'URL: http://www.allapi.net/
 'E-Mail: [email protected]
 Dim Pid As Long
 'Lock the window update
 LockWindowUpdate GetDesktopWindow
 'Execute notepad.Exe
 Pid = Shell("c:\windows\notepad.exe", vbNormalFocus)
 If Pid = 0 Then MsgBox "Error starting the app"
 'retrieve the handle of the window
 mWnd = InstanceToWnd(Pid)
 'Set the notepad's parent
 SetParent mWnd, Me.hwnd
 'Put the focus on notepad
 Putfocus mWnd
 'Unlock windowupdate
 LockWindowUpdate False
End Sub
Private Sub Form\_Unload(Cancel As Integer)
 'Unload notepad
 DestroyWindow mWnd
 'End this program
 TerminateProcess GetCurrentProcess, 0
End Sub

Gruß
J.