Source Code



Kill Active Program

  • anonymous
  • Dec 19' 13
  • Delphi
  • 226
  • 144
  • United States

 

Needed a routine to kill an active program based on classname or window title.  I came up with the following routine

 


 

procedure KillProgram(Classname : string; WindowTitle : string);
const
  PROCESS_TERMINATE = $0001;
var
  ProcessHandle : THandle;
  ProcessID: Integer;
  TheWindow : HWND;
begin
  TheWindow := FindWindow(Classname, WindowTitle);
  GetWindowThreadProcessID(TheWindow, @ProcessID);
  ProcessHandle := OpenProcess(PROCESS_TERMINATE, FALSE, ProcessId);
  TerminateProcess(ProcessHandle,4);
end;

  • Tags : routine, kill, program, delphi
comments powered by Disqus

Related Code

Resizable forms and size grip

Simple Like Function

Suspend the PC

Get current url

Using WinZip as a backup tool

Upper the first letter of each word

Rotate Font

Access the controls of a TRadioGroup

fairly nominal



Category