Announcement

Collapse
No announcement yet.

File close time/date

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

  • File close time/date

    If a file is open, and the computer is powered off, not shut down, just powered off, will the file have the file open time/date or last modified?

    I was thinking (Oh no!), on my Winlog program, if it ran always and updated the file every 5 seconds or every 60 seconds then if the computer were powered off it would be able to read the file on next run and determine the logoff/shutdown time/date....


    No?

    ------------------
    Scott Turchin
    MCSE, MCP+I
    Computer Creations Software
    http://www.tngbbs.com/ccs
    Scott Turchin
    MCSE, MCP+I
    http://www.tngbbs.com
    ----------------------
    True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

  • #2
    If a file is open, and the computer is powered off, not shut down, just powered off, will the file have the file open time/date or last modified?
    Um, try it?

    Of course, the computer should not power off if a file is open, since any program with an open file should be monitoring WM_QUERYENDSESSION and should tell Windows, "NO WAY " when it wants to power off.

    Pulling the plug? (Re-reading, it looks like that's what you mean?)

    Horse of a different color.

    Regardless, this should demonstrate that opening and closing files 'as required' rather than leaving them open should be the 'default' design position. Especially since you can load a whole file into memory to work on the data without changing the 'last write' time.

    MCM




    [This message has been edited by Michael Mattias (edited September 18, 2001).]
    Michael Mattias
    Tal Systems (retired)
    Port Washington WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      Only if the plug is pulled, I need to be able to come back up on next boot up and detect that that is what happened.

      In actuality if I can get away with leaving the file open I will likely keep writing the last modified date in so that the admin console can see the last shutdown.

      Basically the app will detect if the user is pulling the plug or shutting windows down properly.




      ------------------
      Scott Turchin
      MCSE, MCP+I
      Computer Creations Software
      http://www.tngbbs.com/ccs
      Scott Turchin
      MCSE, MCP+I
      http://www.tngbbs.com
      ----------------------
      True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

      Comment


      • #4
        Basically the app will detect if the user is pulling the plug or shutting windows down properly
        Easy way:

        When your program starts, write a record to a file. (Clos file)

        When Windows shuts down (WM_ENDSESSION) or program ends (WM_CLOSE or WM_DESTROY), Append a record to that file indicating how program ended.

        When program next starts, look for second record. If it ain't there, the program terminated abnormally.

        In this scenario, there is absolutely no reason to hold any file open.

        MCM
        Michael Mattias
        Tal Systems (retired)
        Port Washington WI USA
        [email protected]
        http://www.talsystems.com

        Comment


        • #5
          OK I had that one in mind already but here's the problem:
          You have to have an identifier as to whether it is a boot-up time/date or not...how would I know whether the app was terminated.

          Currently that *IS* how it works basically, it logs the date/time and ends the program.

          But, I want ot know if the user is just pulling the plug...
          The WM_QUERYENDSESSION and all that will of course be in there but if it does NOT get shut down properly then the file SHOULD have a 1 in it for example.
          Now on next bootup if that one is there I can read the file/date/time.....provided it is fairly close to when the actual plug was pulled...
          If I open the file and change one byte every minute then it SHOULD work....

          Yeah it ****s leaving a file open but there is no other way to record a power off....



          ------------------
          Scott Turchin
          MCSE, MCP+I
          Computer Creations Software
          http://www.tngbbs.com/ccs
          Scott Turchin
          MCSE, MCP+I
          http://www.tngbbs.com
          ----------------------
          True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

          Comment

          Working...
          X