Need help with close another application

Posted by handoyo on August 27, 2007

Hi guys..I need help please.I got a code that display active application names inside a listbox.Is it possible to close the selected application name inside the listbox???Thx..Here are the codes..
Function EnumWindowsProc (Wnd: HWND; lb: TListbox): BOOL; stdcall;
var
caption: Array [0..128] of Char;
begin
Result := True;
if IsWindowVisible(Wnd) and ((GetWindowLong(Wnd, GWL_HWNDPARENT) = 0) or
(HWND(GetWindowLong(Wnd, GWL_HWNDPARENT)) = GetDesktopWindow)) and
((GetWindowLong(Wnd, GWL_EXSTYLE) and WS_EX_TOOLWINDOW) = 0) then

begin
SendMessage( Wnd, WM_GETTEXT, Sizeof( caption ),integer(@caption));
lb.Items.AddObject( caption, TObject( Wnd ));
end;
end;

procedure TMainForm.GetButtonClick(Sender: TObject);
begin
listbox1.clear; //clear the list box
EnumWindows( @EnumWindowsProc, integer(listbox1)); //get the programs
end;

Follow Ups & Related Articles