Announcement

Collapse
No announcement yet.

Windows wird runtergefahren, was passiert mit meinem Programm?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Windows wird runtergefahren, was passiert mit meinem Programm?

    Wenn man Windows herunterfährt, dann schließt sich mein Programm und alles, was man da gerade offen hat geht verloren. Ich will aber die Informationen in einer TXT-Datei z.B. sichern können.
    FormCloseQuery und OnClose werden nicht aufgerufen. Was kann ich tun?

  • #2
    Hi,

    ein weg wäre es so wie word zu machen. Eine Einstellung programmieren, die dann alle 10minuten oder in einem anderen Interval die Daten speichtert. Das wäre die leichteste Lösung.

    Cu Philipp<br>
    www.preiswerte-tinte.de<br>
    www.loonaticmedia.d

    Comment


    • #3
      danke, dass ist gar keine schlechte Idee, aber ein Kumpel von mir hat schon die Lösung gefunden.

      Detecting Windows Shutdown Mode
      It is possible for you to detect when windows is being shutdown and
      to prevent this shutdown from within a running C++ Builder application.

      The simple solution is to add an event handler to the main form's
      OnCloseQuery event. This event handler occurs as a result of a
      WM_QUERYENDSESSION message which is sent to all running application
      in Windows when Windows is about to be shut down. The boolean
      CanClose parameter to this event can be set to True to allow Windows
      to shut down or, CanClose can be set to False to prevent Windows
      from shutting down.
      The code below illustrates using this event.
      ----- Code Follows -------

      void __fastcall TForm1::FormCloseQuery(TObject *Sender, bool &CanClose)
      {
      // Asks user if shutdown should occur.
      if (MessageDlg("Are you sure?", mtConfirmation, TMsgDlgButtons() << mbOK << mbCancel,0) == mrOk)
      CanClose = true; // Allows Windows to be shut down
      else
      CanClose = false; // Prevent Windows from shutting down

      Comment

      Working...
      X