Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to write the current status in some file when system shuts down with Electricity failure

How to write the current status in some file when system shuts down with Electricity failure

Scheduled Pinned Locked Moved C / C++ / MFC
questiontutorial
11 Posts 7 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z zahid_ash

    Hi, Before closing my application I write down the status of current working in some file. But when the application gets closed after sudden electricity failure, how can I write down the status in a file at that time. any Idea? / link Regards.

    N Offline
    N Offline
    Nibu babu thomas
    wrote on last edited by
    #2

    zahid_ash wrote:

    But when the application gets closed after sudden electricity failure,

    AFAIK there are none. WM_QUERYENDSESSION and others do help only if you are using Shut Down.


    Nibu thomas A Developer Programming tips[^]  My site[^]

    1 Reply Last reply
    0
    • Z zahid_ash

      Hi, Before closing my application I write down the status of current working in some file. But when the application gets closed after sudden electricity failure, how can I write down the status in a file at that time. any Idea? / link Regards.

      E Offline
      E Offline
      Eytukan
      wrote on last edited by
      #3

      How can you write when the system has shut down??:confused: and Btw is this you really ask?


      --[V]--

      [My Current Status]

      Z 1 Reply Last reply
      0
      • E Eytukan

        How can you write when the system has shut down??:confused: and Btw is this you really ask?


        --[V]--

        [My Current Status]

        Z Offline
        Z Offline
        zahid_ash
        wrote on last edited by
        #4

        Mean to say that I want to write in a file( open a file and write status data in it)just before Operating system is shutting down with electricity failure Regards.

        M E L 3 Replies Last reply
        0
        • Z zahid_ash

          Mean to say that I want to write in a file( open a file and write status data in it)just before Operating system is shutting down with electricity failure Regards.

          M Offline
          M Offline
          Mahesh Kulkarni
          wrote on last edited by
          #5

          I don't know how to detect electricity failure . But you can write the system status after some time span continuesly. When system shuts down you have nearest system status in ur file. The secret of life is not enjoyment but education through experience. - Swami Vivekananda.

          1 Reply Last reply
          0
          • Z zahid_ash

            Mean to say that I want to write in a file( open a file and write status data in it)just before Operating system is shutting down with electricity failure Regards.

            E Offline
            E Offline
            Eytukan
            wrote on last edited by
            #6

            As Nimbu has said, QueryEndSession is the only way .. that too when the system is not being shut down abruptly. But if you still want to do, do one thing, write the staus in a remote computer.(i.e a Client machine), which gets data(status) from the server(the electrically-downed machine), now atleast you can write, *when* the system actually went down. like... 09:40:43-29/6/05 - Status X 09:41:23-29/6/05 - Status Y (Now the server is down abrubtly) 09:42:23-29/6/05 - Server Down, [Here the client will still be alive to say that he's down] will this work for you?


            --[V]--

            [My Current Status]

            1 Reply Last reply
            0
            • Z zahid_ash

              Hi, Before closing my application I write down the status of current working in some file. But when the application gets closed after sudden electricity failure, how can I write down the status in a file at that time. any Idea? / link Regards.

              S Offline
              S Offline
              Sarath C
              wrote on last edited by
              #7

              If we can detect the electricity failure, then we do not need of a UPS :) it is only requires if we need continue our work to power failure time :( SaRath

              S 1 Reply Last reply
              0
              • Z zahid_ash

                Mean to say that I want to write in a file( open a file and write status data in it)just before Operating system is shutting down with electricity failure Regards.

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #8

                If you have a UPS (Uniterruptible Power Supply) they send a message to the PC whe nthe mains goes off so you have time to shot down properly while the batteries in the UPS last. Elaine :rose: The tigress is here :-D

                E 1 Reply Last reply
                0
                • S Sarath C

                  If we can detect the electricity failure, then we do not need of a UPS :) it is only requires if we need continue our work to power failure time :( SaRath

                  S Offline
                  S Offline
                  Sebastian Schneider
                  wrote on last edited by
                  #9

                  We cannot. Because at the time that we are able to notice a power failure, it has already happened. And as soon as the hard-disk looses power, it shuts itself down. Yes, theoretically, the failure is not "sudden", but happens over a (very short) time-span. If you wanted to monitor for electrical failure, your computer could not do anything else, because he would have to check Vcore every 1000 cycles or so. And even that probably would not be fast enough to trigger a HDD-Write before the disk spins down. This ONLY works with an UPS, which will notify Windows that "you are on battery now. save everything you can.". All UPSes allow some kind of status monitoring, but you might have to install propietary drivers for older or more sophisticated models. What I was going to say originally: "You should really try to claim damages toward your local power company for not notifying you (in written form) two days in advance of any unplanned power failure." But I thought that was too harsh. Cheers, Sebastian -- Contra vim mortem non est medicamen in hortem.

                  1 Reply Last reply
                  0
                  • L Lost User

                    If you have a UPS (Uniterruptible Power Supply) they send a message to the PC whe nthe mains goes off so you have time to shot down properly while the batteries in the UPS last. Elaine :rose: The tigress is here :-D

                    E Offline
                    E Offline
                    Eytukan
                    wrote on last edited by
                    #10

                    Excellent Elaine, I didn't think of this idea. This would be the best option for him. But he must ensure that his UPS is enabled with communication port. Here in India, I find only APC providing that feature. That too not for the lower ends. I checked a model on the internet that had USB port, and I bought it home immediately. When I unpacked it, I found no *holes* around :(.I got disappointed. I called the customer care, they said, it's available only with the Japanese model :((.


                    --[V]--

                    [My Current Status]

                    L 1 Reply Last reply
                    0
                    • E Eytukan

                      Excellent Elaine, I didn't think of this idea. This would be the best option for him. But he must ensure that his UPS is enabled with communication port. Here in India, I find only APC providing that feature. That too not for the lower ends. I checked a model on the internet that had USB port, and I bought it home immediately. When I unpacked it, I found no *holes* around :(.I got disappointed. I called the customer care, they said, it's available only with the Japanese model :((.


                      --[V]--

                      [My Current Status]

                      L Offline
                      L Offline
                      Lost User
                      wrote on last edited by
                      #11

                      :wtf: The tigress is here :-D

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups