skatan187
asked on
closing other running applications
How can I close/kill/interrupt a running application/dll/... from my delphi application?
SkAtAn
SkAtAn
Send it a WM_QUIT message or use TerminateProcess...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If you want the program to ask the user if he/she wants to save the currently opened file, you have to send a WM_CLOSE to the main window.
If you don't like this, send a WM_QUIT either to the main window or (and that is what I'm normally doing) to the main thread by using PostThreadMessage(tid,WM_Q UIT,0,0);
You can use TerminateProcess, too. But that's quite ugly, because it does NOT perform a CLEAN program shutdown. (Read the documentation of TerminateProcess)
Regards, Madshi.
If you don't like this, send a WM_QUIT either to the main window or (and that is what I'm normally doing) to the main thread by using PostThreadMessage(tid,WM_Q
You can use TerminateProcess, too. But that's quite ugly, because it does NOT perform a CLEAN program shutdown. (Read the documentation of TerminateProcess)
Regards, Madshi.
ASKER
Ok this worked.. is there alse a way to get all running application (titles) in a tstrings/list/array ?
SkAtan
SkAtan
If you look at this question (hurry, it's still open in the moment)
https://www.experts-exchange.com/topics/comp/lang/delphi/Q.10117362
you'll find a solution for that for win95/98.
If you need it to run under NT4, too, and you have Delphi 4, you can download my "enumStuff" unit from my homepage "http://www.madshi.com" in the "sources" section. This unit gives you some handy functions to enumerate all running applications, but it runs only under Delphi 4.
Regards, Madshi.
https://www.experts-exchange.com/topics/comp/lang/delphi/Q.10117362
you'll find a solution for that for win95/98.
If you need it to run under NT4, too, and you have Delphi 4, you can download my "enumStuff" unit from my homepage "http://www.madshi.com" in the "sources" section. This unit gives you some handy functions to enumerate all running applications, but it runs only under Delphi 4.
Regards, Madshi.
ASKER
ok thx alot.. Madshi
and viktornet for the correct answer :-)
SkAtAn
and viktornet for the correct answer :-)
SkAtAn
ASKER
>>
You can use TerminateProcess, too. But that's quite ugly, because it does NOT perform a CLEAN program shutdown. (Read the documentation of TerminateProcess)
<<
jep.. this is what I need.. the program ABSOLUTLY MUST SHUT DOWN without doing furter actions.. I already accepted this question.. but ofcourse you may gimme a sample for this.. (probebly I'll find it myself.. oh well! :-)
SkAtan
You can use TerminateProcess, too. But that's quite ugly, because it does NOT perform a CLEAN program shutdown. (Read the documentation of TerminateProcess)
<<
jep.. this is what I need.. the program ABSOLUTLY MUST SHUT DOWN without doing furter actions.. I already accepted this question.. but ofcourse you may gimme a sample for this.. (probebly I'll find it myself.. oh well! :-)
SkAtan
Use this function. But you must give in the processID of the process you want to shut down. You get the processID from both the sources of the other question I mentioned or from the functions in my "enumStuff" unit.
procedure ShutUp_Process(processID: cardinal);
var c1 : cardinal;
begin
c1:=OpenProcess(PROCESS_AL L_ACCESS,f alse,pid);
if c1<>0 then
try
TerminateProcess(c1,0);
finally CloseHandle(c1) end;
end;
Regards, Madshi.
procedure ShutUp_Process(processID: cardinal);
var c1 : cardinal;
begin
c1:=OpenProcess(PROCESS_AL
if c1<>0 then
try
TerminateProcess(c1,0);
finally CloseHandle(c1) end;
end;
Regards, Madshi.
you can use EnumWindows() to get all windows in a TStringList or Listbox or whatever..if you need an example let me know.... yeah Madshi is right.. TerminateProcess() is another way to shut down a process...
Madshi, you've given your procedure a nice name :))
-Viktor
--Ivanov
Madshi, you've given your procedure a nice name :))
-Viktor
--Ivanov