Process killer

Contenu du snippet

C'est à la mode de jouer avec les <FONT COLOR=#0000BB FACE=Arial>process</FONT>, alors pkoi pas.. c't'app permet de lister les <FONT COLOR=#0000BB FACE=Arial>process</FONT> en cours d'exécution et de tuer celui que vous voulez ( de façon sauvage ) en leur envoyant un signal de fin d'exécution de manière <U>verticale et en avant</U>.

Nécessite une Form, un Label et une ListBox

Source / Exemple :


Private Declare Function RecupLaFenetre Lib "user32" Alias "GetWindow" _
                        (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Private Declare Function RecupLePidDuPapa Lib "user32" Alias "GetParent" _
                                              (ByVal hwnd As Long) As Long
Private Declare Function RecupLaLongueurDeLeTexte Lib "user32" Alias _
                   "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Private Declare Function RecupLeTexte Lib "user32" Alias "GetWindowTextA" _
  (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Declare Function ModifLeTexte Lib "user32" Alias "SetWindowTextA" _
                     (ByVal hwnd As Long, ByVal lpString As String) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
   (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SendMessageA Lib "user32" (ByVal hwnd As Integer, _
      ByVal wMsg As Integer, ByVal wParam As Integer, lParam As Any) As Long

Const WANNAKILL = &H10

Private Sub Form_Load()
 Call InitBg
 Call LoadTaskList
End Sub

Private Sub List1_DblClick()
 Call KillThisApp(List1.List(List1.ListIndex))
 List1.RemoveItem List1.ListIndex
End Sub

Sub InitBg()
 List1.Top = 280: List1.Left = 0: List1.Appearance = 0
 List1.Width = 3000: List1.Height = 2400: List1.BackColor = &H80000018
 Label1.FontName = "Arial": Label1.FontUnderline = True: Label1.Width = 4000
 Label1.Top = 30: Label1.Left = 300: Label1.Caption = "Double click pour tuer le process"
 Me.Width = 3100: Me.Height = 3060
 Me.Caption = "Mémère Killer"
 Me.Top = Int((Screen.Height - Me.Height) / 2)
 Me.Left = Int((Screen.Width - Me.Width) / 2)
End Sub

Sub LoadTaskList()
 Dim CurrWnd As Long
 Dim LongueurDeLeNom As Long
 Dim TaskName As String
 Dim Parent As Long

 CurrWnd = RecupLaFenetre(Form1.hwnd, 0)
 gIndex = 0
 While CurrWnd <> 0
  Parent = RecupLePidDuPapa(CurrWnd)
  LongueurDeLeNom = RecupLaLongueurDeLeTexte(CurrWnd)
  TaskName = Space$(LongueurDeLeNom + 1)
  Length = RecupLeTexte(CurrWnd, TaskName, LongueurDeLeNom + 1)
  TaskName = Left$(TaskName, Len(TaskName) - 1)
  If Length > 0 And gIndex < 200 Then
   If TaskName <> Me.Caption Then List1.AddItem TaskName
   gIndex = gIndex + 1
  End If
  CurrWnd = RecupLaFenetre(CurrWnd, 2)
  DoEvents
 Wend
End Sub

Private Sub KillThisApp(LeProcess)
 SendMessageA FindWindow(vbNullString, LeProcess), WANNAKILL, 0, 0
End Sub

Conclusion :


<CENTER><IMG SRC='http://manipulator.free.fr/captures/killer.jpg' WIDTH=305 HEIGHT=288></CENTER>

<U>Remarquez</U> que si le process est déja en vrac, vous avez une chance sur deux de l'arrêter alors qu'en passant par Ctrl+Alt+Suppr, vos chances sont limitées.

A voir également

Vous n'êtes pas encore membre ?

inscrivez-vous, c'est gratuit et ça prend moins d'une minute !

Les membres obtiennent plus de réponses que les utilisateurs anonymes.

Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.

Le fait d'être membre vous permet d'avoir des options supplémentaires.