Delphi-PRAXiS
Seite 1 von 3  1 23      

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Anti End Task, not WM_Close? (https://www.delphipraxis.net/157176-anti-end-task-not-wm_close.html)

user 1. Jan 2011 19:56

Anti End Task, not WM_Close?
 
To prevent WM_Close, I use

Code:
procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
CanClose := false
end;
Try to click End Task with TaskManager, after several seconds, there will be an end task dialog then the app can be killed. How to prevent this? I just want to prevent End Task.

Dezipaitor 1. Jan 2011 20:04

AW: Anti End Task, not WM_Close?
 
Call getsystemmetrics with SM_SHUTTINGDOWN and set CanClose to true in such a case.

BTW: Your app is not user friendly. However, in the end the user will always be able to close your application. It just takes a little more effort.

user 1. Jan 2011 20:07

AW: Anti End Task, not WM_Close?
 
Zitat:

Zitat von Dezipaitor (Beitrag 1071668)
Call getsystemmetrics with SM_SHUTTINGDOWN and set CanClose to true in such a case.

BTW: Your app is not user friendly. However, in the end the user will always be able to close your application. It just takes a little more effort.

I'll try "getsystemmetrics with SM_SHUTTINGDOWN". Yeah I just want to prevent end task. I know there are many ways to kill an app. No I'm not making virus! :)


edited :
Code:
SM_BASE = WM_USER +  1736 ;
SM_SHUTTINGDOWN = SM_BASE +2;

procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
CanClose:=false;
if (GetSystemMetrics (SM_SHUTTINGDOWN) <> 0) then
CanClose:=false;
end;
The code is right?

rollstuhlfahrer 1. Jan 2011 20:34

AW: Anti End Task, not WM_Close?
 
Zitat:

Zitat von user (Beitrag 1071669)
edited :
Code:
SM_BASE = WM_USER +  1736 ;
SM_SHUTTINGDOWN = SM_BASE +2;

procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
CanClose:=false;
if (GetSystemMetrics (SM_SHUTTINGDOWN) <> 0) then
CanClose:=false;
end;
The code is right?

Can't be right. You don't set CanClose to true in any case. It has to be
Delphi-Quellcode:
if (GetSystemMetrics (SM_SHUTTINGDOWN) <> 0) then
CanClose := true;
Bernhard

user 1. Jan 2011 20:43

AW: Anti End Task, not WM_Close?
 
Zitat:

Zitat von rollstuhlfahrer (Beitrag 1071678)

Can't be right. You don't set CanClose to true in any case. It has to be
Delphi-Quellcode:
if (GetSystemMetrics (SM_SHUTTINGDOWN) <> 0) then
CanClose := true;
Bernhard

Still not working. I also change the value of SM_SHUTTINGDOWN to 2000 (referenced from MSDN). I am using 7 32 bit.

Luckie 1. Jan 2011 20:43

AW: Anti End Task, not WM_Close?
 
And what's the use of it? If I want to end your application I just will call ProcessTerminate and that's it. Even a normal user cab do this. He just has to switch to the process panel of the taskmanager. Users ain't silly.

user 1. Jan 2011 20:45

AW: Anti End Task, not WM_Close?
 
Zitat:

Zitat von Luckie (Beitrag 1071682)
And what's the use of it? If I want to end your application I just will call ProcessTerminate and that's it. Even a normal user cab do this. He just has to switch to the process panel of the taskmanager. Users ain't silly.

I already hook TerminateProcess.

rollstuhlfahrer 1. Jan 2011 20:49

AW: Anti End Task, not WM_Close?
 
Why hook ProcessTerminate? - You just need to hook OpenProcess.
But why do you do so? - Just create a process with Admin-Account and don't let the user get Admin-Rights and your process acts like it should, cause a Non-Admin can't terminate Processes from an Admin-Account. Or create a service.

Bernhard

user 1. Jan 2011 21:03

AW: Anti End Task, not WM_Close?
 
Zitat:

Zitat von rollstuhlfahrer (Beitrag 1071684)
Why hook ProcessTerminate? - You just need to hook OpenProcess.
But why do you do so? - Just create a process with Admin-Account and don't let the user get Admin-Rights and your process acts like it should, cause a Non-Admin can't terminate Processes from an Admin-Account. Or create a service.

Bernhard

Yes, hooking XxOpenProcess maybe better than hooking XxProcessTerminate. I'll implement that later. No, user can use my app in Admin-Account. My problem is user can kill my app from end task.

rollstuhlfahrer 1. Jan 2011 21:08

AW: Anti End Task, not WM_Close?
 
Why do you need a not-closable Application?

Bernhard


Alle Zeitangaben in WEZ +1. Es ist jetzt 01:10 Uhr.
Seite 1 von 3  1 23      

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz