Solved

Kill process under Windows NT

Posted on 2001-07-10
7
418 Views
Last Modified: 2010-04-06
How can I kill the Windows process "excel.exe" in Delphi ?
0
Comment
Question by:SChatel
7 Comments
 
LVL 13

Expert Comment

by:Epsylon
ID: 6269487
uses ComObj;

procedure TForm1.Button1Click(Sender: TObject);
var
  Excel: Variant;
begin
  try
    Excel := GetActiveOleObject('Excel.Application');
  except
    Excel := CreateOleObject('Excel.Application');
  end;
  Excel.DisplayAlerts := False;
  Excel.Quit;
  Excel := Unassigned;
end;
0
 
LVL 6

Expert Comment

by:Jaymol
ID: 6269738
This will close Excel nicely, asking the user if they wish to save any changes (if it's relevant.)

  SendMessage(FindWindow('XLMAIN', nil), WM_CLOSE, 0, 0);

Hope this helps,

John.
0
 
LVL 1

Expert Comment

by:BlackDeath
ID: 6269887
;-)

go to dos prompt and just say:

kill -f excel.exe

and all instances of excel will be killed, file open or not, regardlessly of any losses...

nice tool, that kill...

bye,

BlackDeath.
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

Author Comment

by:SChatel
ID: 6269893
Jaymol,
It works but only if I close my Delphi application
0
 
LVL 1

Expert Comment

by:BlackDeath
ID: 6269895
eh - for use in delphi use API-function ShellExecute or ShellExecuteEx, as you like.
0
 
LVL 1

Expert Comment

by:BlackDeath
ID: 6269933
and if you want excel to ask you, if the changes should be saved - well, then use

kill excel.exe

with out -f (stands for "force")

kill.exe ist part of the resource kit for windows you can download.

BD.
0
 
LVL 21

Accepted Solution

by:
ziolko earned 50 total points
ID: 6272001
Check out my previouse Q:
/jsp/qManageQuestion.jsp?ta=delphi&qid=10372556
You can kill anything not only excel :-)))
ziolko/
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question