Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Delphi Programm vorgaukeln, dass Windows heruntergefahren wird... (https://www.delphipraxis.net/100346-programm-vorgaukeln-dass-windows-heruntergefahren-wird.html)

FriFra 26. Sep 2007 18:53


Programm vorgaukeln, dass Windows heruntergefahren wird...
 
Ich möchte ein Programm schließen. Mein Problem ist, dass dieses bei WM_CLOSE einen Bestätigungsdialog öffnet, den ich in dem Moment nicht gebrauchen kann. Beim herunterfahren von Windows, beendet sich das Programm jedoch silent -> Kann ich dem Programm nicht auch direkt eine Message senden, dass es "glaubt", Windows wird herunter gefahren?

s-off 26. Sep 2007 18:54

Re: Programm vorgaukeln, dass Windows heruntergefahren wird.
 
Hallo,

schicke ihm die WM_QUERYENDSESSION. Damit stellt man sicher, dass eine Anwendung sich selber beendet, wenn Windows heruntergefahren wird, indem man die Message mit '1' beantwortet.

FriFra 27. Sep 2007 20:59

Re: Programm vorgaukeln, dass Windows heruntergefahren wird.
 
Danke, das wars... allerdings wird das Programm, welches ich beenden wollte damit zwar erstmal ohne den sonst üblichen Dialog beendet, aber danach läuft es nicht mehr sauber, so dass ich jetzt zu härteren Mitteln (Task abschießen) gegriffen habe.

jfheins 27. Sep 2007 21:56

Re: Programm vorgaukeln, dass Windows heruntergefahren wird.
 
Hast du das auch beachtet:
Zitat:

When an application returns TRUE for this message, it receives the WM_ENDSESSION message, ...
http://msdn2.microsoft.com/en-us/library/aa376890.aspx

Du musst also noch WM_ENDSESSION senden ;)

Beides mit den Cloaseapp Einstellungen und dann noch ein WM_QUIT sollte eigentlich das Programm beenden, ohne es abschießen zu müssen :gruebel:

Bernhard Geyer 27. Sep 2007 22:27

Re: Programm vorgaukeln, dass Windows heruntergefahren wird.
 
Bedenkt aber

1, Unter Vista können (vermutlich) nur Apps mit den gleichen Rechten damit "versorgt" werden (Trennung Admin <-> User-Apps)
2, Falls hier (noch) ein Sicherheitsloch vorhanden sein könnte, MS diese einfach nicht mehr zustellt.

Remko 29. Sep 2007 20:24

Re: Programm vorgaukeln, dass Windows heruntergefahren wird.
 
You could also use the EndTask function and specify True for the last parameter.

OregonGhost 30. Sep 2007 12:02

Re: Programm vorgaukeln, dass Windows heruntergefahren wird.
 
Zitat:

Zitat von EndTask-Doku
Although you can access this function by using LoadLibrary and GetProcAddress combined in Microsoft Windows versions prior to Windows XP, the function is not accessible using the standard Include file and library linkage. The header files included in Windows XP Service Pack 1 (SP1) and Windows Server 2003 document this function and make it accessible using the appropriate Include file and library linkage. However, this function is not intended for general use. It is recommended that you do not use it in new programs because it might be altered or unavailable in subsequent versions of Windows.


Remko 30. Sep 2007 12:21

Re: Programm vorgaukeln, dass Windows heruntergefahren wird.
 
I know, this is true for several other less known api's. It means: "we were forced to document these api's due to the trust settlements. We hate that and therefore we (MS) encourage others not to use them, although we use them ourselves...". I think that since this function is present from win2000 upwards and still is in Vista it's allright to use it. But if you don't feel comfortable...
You could try WtsTerminateProcess instead.


Alle Zeitangaben in WEZ +1. Es ist jetzt 06:49 Uhr.

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