Closing other applications from my app

i want to kill other applications but i dunno how, i'm a beginner in Delphi programming! please help me !
Thanks!

Comments

  • : i want to kill other applications but i dunno how, i'm a beginner in Delphi programming! please help me !
    : Thanks!
    :
    hi

    i can't tell u how to kill other processes,
    but i think that u should take a look at the message system of windows.
    I think u can send a quit message. i didn't do any research on it but give it a try :)
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/messagesandmessagequeues/aboutmessagesandmessagequeues.asp

    i hope this helps u.

    Greetz DJ Sannie.
  • : i want to kill other applications but i dunno how, i'm a beginner in Delphi programming! please help me !
    : Thanks!
    :

    You can use EnumWindows (you can search all windows) or FindWindow (you can find windows by theri name or class) to get window handle witch you want to kill and then use PostMessage to send WM_QUIT message. It almost allways works ;)

  • : : i want to kill other applications but i dunno how, i'm a beginner in Delphi programming! please help me !
    : : Thanks!
    : :
    :
    : You can use EnumWindows (you can search all windows) or FindWindow (you can find windows by theri name or class) to get window handle witch you want to kill and then use PostMessage to send WM_QUIT message. It almost allways works ;)
    :
    :
    This is really helpful input but can anyone pls. elaborate more. Thanks. :)
  • To find wondows witch names you know use something like this (you cann't find child windows, only top level ones):

    For I:=1 to MaxNames do
    begin
    W:=FindWindow(nil, WinNames[I]);
    if W<>0 then PostMessage(W, WM_QUIT, 0, 0);
    end;

    You fill WinNames array with null-terminated strings witch contain names of windows you want to find. If window with that name exist W will contain handle to that window and you send WM_QUIT message to close it. There is also FindWindowEx function witch can find even child windows. You can find more information about these functions in Delphi Help.

    To use EnumWindows you can write something like this:

    function EnumWinProc(W:HWND; Param:Integer): Boolean;
    begin
    if CheckWin(W) then PostMessage(W, WM_QUIT, 0, 0); {CheckWin should check is W window witch should be closed}
    EnumWinProc:=True; {if you return false the enumeration will stop}
    end;

    When you declare this function you call EnumWindows(EnumWinProc, Param) when you need to close windows. Param is Integer variable witch will be passed to your callback (EnumWinProc) function.

    There is more window enumeration functions. Look in Delphi Help for more information.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories