Solved

Kill process under Windows NT

Posted on 2001-07-10
7
415 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

862 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now