I'm talking about killing another application here...
I need some ways to close an app, so i'm gonna make an
app to do it. I made an old app to do it, but there is one
critical difference...

The new app doesn't have a parent window! *or at least is
doesn't use a window class, or title.. I'm not sure about the
technicalities on the definition 'window', thats all.

I need the names of a couple functions, if you wouldn't mind..

First, I need something that can get the handle to a program,
so I can send WM_DESTROY with PostMessage or SendMessage.

I used to use FindWindow, but this program doesn't use
a title or class.. It just runs, and hides in memory.

I just need a function that can find an apps handle based
on the executable name, or something else (preferable exe name).

Also, are there other ways to close an app? What if it doesn't
want to close? Couldn't it just catch WM_DESTROY before it
reaches itself?
Posted on 2002-02-07 18:54:16 by matthew
If your trying to create a program to kill other windows / applications, then I should mention that this topic has been discussed before :)

You'll probably get a quicker more complete response to this topic by doing a search for "kill" "application"

I'm sure you'll also get source on "said" program too...
Making your life just a little bit easier

If not? then maybe I didn't understand you...

Posted on 2002-02-07 18:58:19 by Sliver
Actually I think it was matthew who discussed this earlier on.

It seems that he has run into a problem were he can't use the find window send message combination because the program does not conform to the windows window standards. Am I right?

If so maybe the name of the program that you want to KILL might help.
Posted on 2002-02-07 19:34:56 by -T-
I had two discussions on it before. One was about an error in the
algorithm i had for closing an app via FindWindow and PostMessage.
Moot point now..

The other never really got a usefull answer, it was about finding
an app based on the EXE, also.. but like I said.. no solution.

The app is fairly irrevelant, but it isn't that it doesn't conform
to any standards. It just runs, and it doesn't call CreateWindowEx
or make any dialogs.. so it doesn't have a window title or class...

All it does is run, and hide in the background doing tasks.

I COULD find the HWND with a tool while working on the computer,
but i want the program to be able to find the hwnd itself...

Therefore, the only way to close the app that I can think of would
be based on the image (exe) name..
Posted on 2002-02-07 20:05:43 by matthew
I COULD find the HWND with a tool while working on the computer, but i want the program to be able to find the hwnd itself...

Hang on, you just finished telling us that it has no window, so how can it have an hWnd?

In your case, i would suggest that you do a EnumProcesses, then EnumProcessModules, then cycle through the list of module handles and do a GetModuleBaseName or GetModuleFileNameEx on each one to identify it.

WM_DESTROY probably will not work for an app with no window, try a WM_QUIT instead. If it refuses to shut down, use TerminateProcess.
Posted on 2002-02-07 21:14:35 by sluggy

There are a couple of tricks that may help you if the method you are using does not create a window of some type that has a corresponding WndProc message handler.

The easiest one that comes to mind is to start a normal window off the screen and react with it in the normal manner for a windows program.

If you really want to use a fully NON window program, you will need to find a way for it to monitor what is happening in the operating system.

If you can set up some form of loop in the NON window application which would be necessary for it to keep running, try registering a private message within the app and use PeekMessage to see if you can get the message when it is sent as a HWND_BROADCAST message.

Its not a "nice" way to do it but it may work.


Posted on 2002-02-07 21:48:43 by hutch--