![]() |
Anwendung im Tray = Rechner fährt nicht runter???
Also eigendlich klappt das so wie ich es wollte.
Anwendung wird minimiert und neben der Uhr angezeigt. Toll... ;)
Delphi-Quellcode:
Was allerdings nicht geht und deshalb meld ich mich hier zu Wort ist wenn die Anwendung neben der Uhr liegt und ich den Rechner runterfahren möchte.
procedure HideTheApplication;
begin ShowWindow(Application.Handle, SW_HIDE); frmMain.TrayIconMain.Visible:=True; end; procedure ShowTheApplication; begin frmMain.TrayIconMain.Visible:=False; ShowWindow(Application.Handle, SW_SHOW); Application.Restore; end; procedure TfrmMain.ApplicationEventsMinimize(Sender: TObject); begin HideTheApplication; end; Dann muß ich die Anwendung erst aus dem Tray holen, diese dann beenden und dann nochmal auf Runterfahren drücken. Warum ist das so? Wie kann meine Anwendung mitbekommen das Feierabend ist? Gruß Frank |
Re: Anwendung im Tray = Rechner fährt nicht runter???
Probier dasmal
Delphi-Quellcode:
function MyExitWindows(RebootParam: Longword): Boolean;
var TTokenHd: THandle; TTokenPvg: TTokenPrivileges; cbtpPrevious: DWORD; rTTokenPvg: TTokenPrivileges; pcbtpPreviousRequired: DWORD; tpResult: Boolean; const SE_SHUTDOWN_NAME = 'SeShutdownPrivilege'; begin if Win32Platform = VER_PLATFORM_WIN32_NT then begin tpResult := OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY, TTokenHd); if tpResult then begin tpResult := LookupPrivilegeValue(nil,SE_SHUTDOWN_NAME,TTokenPvg.Privileges[0].Luid); TTokenPvg.PrivilegeCount := 1; TTokenPvg.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED; cbtpPrevious := SizeOf(rTTokenPvg); pcbtpPreviousRequired := 0; if tpResult then Windows.AdjustTokenPrivileges(TTokenHd,False,TTokenPvg,cbtpPrevious,rTTokenPvg,pcbtpPreviousRequired); end; end; Result:= ExitWindowsEx(RebootParam, 0); end; MyExitWindows(EWX_POWEROFF or EWX_FORCE); Gruß Sascha |
Re: Anwendung im Tray = Rechner fährt nicht runter???
Ein einfaches
Delphi-Quellcode:
tut's auch ;)
procedure TForm1.WMQueryEndSession(var Message: TWMQueryEndSession);
begin inherited; Message.Result := 1; end; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 03:23 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz