|
-
September 28th, 2005, 09:43 PM
#1
How to close the exe program?
I know by using ShellExecute, we can execute the exe program. On the other hand, if we want to kill the program by programming code, how to do?
-
September 28th, 2005, 10:06 PM
#2
Re: How to close the exe program?
Which process you want to kill?
Was that process created by you? That means if you have HANDLE to that process you can use TerminateProcess (NOT recommened!).
If you wish to terminate a Windows Application (that has window), you can use FindWindow[Ex] to find the window handle and then ask the process by sending WM_DESTROY message to the main window. If you already have HWND of the main window of the process you want to terminate, just send the WM_DESTROY message to it.
When you terminate using WM_DESTORY, the process is given a chance to save its data and state and may also ignore the termination request. From "Applications" tab of task manager, when you click "End Task" this method is used by TM.
When you issue "End Process" from "Processes" tab, TerminateProcess is issued.
-
September 28th, 2005, 10:37 PM
#3
Re: How to close the exe program?
Do you mean WM_CLOSE, instead of WM_DESTROY?
-
September 28th, 2005, 10:49 PM
#4
Re: How to close the exe program?
Ohh yes, my mistake... It is WM_CLOSE message.
Actually, I was confused with CloseWindow API, that does minimizes the window...
-
September 29th, 2005, 12:56 AM
#5
Re: How to close the exe program?
Sorry, i don't know how WM_CLOSE work. Actually, i am not gonna to close the present window. My meaning is, i have another program now running, for example "program1.exe". I want to kill it by another program "program2.exe" by push a button. But program2 still running. How to do?
-
September 29th, 2005, 01:39 AM
#6
Re: How to close the exe program?
Take a look at Message Sender. It is based upon the concept provied by Ajay Vijay.
-
September 29th, 2005, 02:28 AM
#7
Re: How to close the exe program?
-
September 29th, 2005, 02:49 AM
#8
Re: How to close the exe program?
My meaning is, i have another program now running, for example "program1.exe". I want to kill it by another program "program2.exe" by push a button. But program2 still running. How to do?
If u want to kill process just like Taskmanager EndTask then u can use the following set of APIs aswell.
Code:
EnumProcesses
OpenProcess
EnumProcessModules
GetModuleBaseName
TerminateProcess
Hope this will helps u.
A Person who is polite is given goodness and a person who is away from Politeness is away from Goodness.
NAUMAAN
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|