?
Solved

CanClose

Posted on 2000-03-02
9
Medium Priority
?
155 Views
Last Modified: 2012-05-04
How can I close a Delphi-made program which has the CanClose property set to False? (might add: another program, not my own)

CloseWindow(hWnd); doesn't work!

Neither does DestroyWindow(hWnd);!

Plz help!

johan
0
Comment
Question by:sageryd
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
9 Comments
 
LVL 13

Expert Comment

by:Epsylon
ID: 2578267
Use:

Application.Terminate;


Regards,

Epsylon.
0
 
LVL 1

Author Comment

by:sageryd
ID: 2578284
Well, as I said, it is not my own app that I want to terminate, it's another app, another process!
0
 
LVL 1

Author Comment

by:sageryd
ID: 2578295
Well, as I said, it is not my own app that I want to terminate, it's another app, another process!
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 17

Accepted Solution

by:
inthe earned 400 total points
ID: 2578327
Hi
if you can find out the class name of the window then you can do:

procedure TForm1.Button1Click(Sender: TObject);
var
h : thandle;
ProcessID,cpid : Cardinal;
begin
h := findwindow('classnameof window',nil);
ProcessID := GetWindowThreadProcessID(h,@cpid);
TerminateProcess(OpenProcess(PROCESS_TERMINATE,false,cpid),1);
end;


or if you cant get the class name use madshis enumstuff unit to do it:

http://nettrash.com/users/madshi/

then can do:

uses Enumstuff;

Procedure Killapp(exeFile: string);
var pl : TProcessList;
    i1 : integer;
     h : thandle;
begin
  pl:=GetProcessList;
  for i1:=0 to high(pl) do
    if CompareText(ExtractFileName(pl[i1].name),ExtractFileName(exeFile))=0 then begin
 h := openprocess(PROCESS_TERMINATE,false,pl[i1].pid);
   TerminateProcess(h,0);
   closehandle(h);
      exit;
    end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
killapp('notepad.exe')
end;


Regards Barry
0
 
LVL 1

Author Comment

by:sageryd
ID: 2578354
Thanx!
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 2578368
I think TerminateProcess will do but I don't know how to find the right ProcessID.
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 2578369
:o)
0
 
LVL 17

Expert Comment

by:inthe
ID: 2578372
:o)
0
 
LVL 1

Author Comment

by:sageryd
ID: 2579332
;o)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month11 days, 10 hours left to enroll

752 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