how can i kill windows with their handels

if i only have the window classname and handle how can i kill his proccess?

Thanks,Daniel.
LVL 2
saar071697Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
intheConnect With a Mentor Commented:
you can use:

PostMessage(Handle, WM_CLOSE, 0, 0);

or wm_quit but close is better as it gives the app (notepad for instance) a chance to ask if any changes are to be saved.
Regards Barry
0
 
kretzschmarCommented:
hi saar,

did you tried,

sendmessage(YourHandle,WM_CLOSE,0,0);
or
sendmessage(YourHandle,WM_QUIT,0,0);

meikl
0
 
kretzschmarCommented:
hi barry,

allways fast,
well postmessage with wm_close is the best choice.

meikl ;-)
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
intheCommented:
have to be fast to keep up with you ;-)
0
 
DValeryCommented:
I'm recomend to look on Madshi Site http://nettrash.com/users/madshi/

Valery
0
 
kretzschmarCommented:
hi barry,
its hard enough to keep you on distance ;-)

hi valery,
yes, madshis site is a good one

meikl
0
 
MadshiCommented:
Thanx, guys...   :-)

Well, you should not send WM_QUIT to a window handle. So my recommendation is one of these 3 things:

(1) PostMessage(windowHandle, WM_CLOSE, 0, 0);
(2) PostThreadMessage(GetWindowThreadProcessID(windowHandle, nil), WM_QUIT, 0, 0);
(3)
var pid : dword;
    ph  : dword;
begin
  GetWindowThreadProcessID(windowHandle, @pid);
  ph := OpenProcess(PROCESS_TERMINATE, false, pid);
  if ph <> 0 then
    try
      TerminateProcess(ph, 0);
    finally CloseHandle(ph);
end;

Perhaps you'll have to make some minor corrections to choice (3), because I've not test-compiled it.

If you want the user to be asked whether he wants to save the opened files, you should go with (1), else you should go with (2) or (3).

Regards, Madshi.
0
All Courses

From novice to tech pro — start learning today.