Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 428
  • Last Modified:

Kill process under Windows NT

How can I kill the Windows process "excel.exe" in Delphi ?
0
SChatel
Asked:
SChatel
1 Solution
 
EpsylonCommented:
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
 
JaymolCommented:
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
 
BlackDeathCommented:
;-)

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
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
SChatelAuthor Commented:
Jaymol,
It works but only if I close my Delphi application
0
 
BlackDeathCommented:
eh - for use in delphi use API-function ShellExecute or ShellExecuteEx, as you like.
0
 
BlackDeathCommented:
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
 
ziolkoCommented:
Check out my previouse Q:
/jsp/qManageQuestion.jsp?ta=delphi&qid=10372556
You can kill anything not only excel :-)))
ziolko/
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

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.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now