Search results for 'WMQueryEndSession'. 1 post(s) found.
- 2007/09/19 Detecting and preventing Windows shut down
When Windows is about to Shut Down, it sends a WM_QueryEndSession to all open applications. To detect (and Prevent Shutdown) , we must define a message handler to this message. Put this definition on the private section of the main form:
Also, to prevent Windows shutting down put this method in the implementation section of the unit:
procedure TForm1.WMQueryEndSession(var Msg : TWMQueryEndSession) ;
begin
if MessageDlg('Close Windows ?',
mtConfirmation,
[mbYes,mbNo], 0) = mrNo then
Msg.Result := 0
else
Msg.Result := 1 ;
end;
begin
if MessageDlg('Close Windows ?',
mtConfirmation,
[mbYes,mbNo], 0) = mrNo then
Msg.Result := 0
else
Msg.Result := 1 ;
end;
To detect Windows Shutdown, we must trap the WM_EndSession message. Declare a message handling procedure in your main Form's Private section:
Also, add the following procedure to the implementation section of your Unit:
procedure TForm1.WMEndSession(var Msg : TWMEndSession) ;
begin
if Msg.EndSession = TRUE then
ShowMessage('Windows is shutting down ' + #10#13
+ 'at ' + FormatDateTime('c', Now)) ;
inherited;
end;
begin
if Msg.EndSession = TRUE then
ShowMessage('Windows is shutting down ' + #10#13
+ 'at ' + FormatDateTime('c', Now)) ;
inherited;
end;
Another posts included in "Delphi"
| Detecting Drive Types (0) | 2007/09/19 |
| Disable Mouse and Keyboard from Delphi Code (0) | 2007/09/19 |
| Display Standard Windows Properties dialog (0) | 2007/09/19 |
| Create new program group in the Start menu (0) | 2007/09/19 |
| Copying Group of Files using Delphi with Standard Animation Dialog (SHF... (0) | 2007/09/19 |
| Controling sound volume from code (0) | 2007/09/19 |
| How to Close Another Application by Windows Caption (0) | 2007/09/19 |
| How to Change the Windows Start button bitmap (0) | 2007/09/19 |
Trackback : Cannot send a trackbact to this post.
-
Subject different money making ideas
2010/01/29 00:38
moneyideas
-
Subject different money making ideas
2010/01/29 09:11
moneyideas
-
Subject different money making ideas
2010/01/31 16:40
moneyideas

Prev

Rss Feed