Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2014-08

Obtaining uptime

17 messages · 8 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Richard Mace

Hi,
Does anyone know why the following code returns the correct days uptime in XP, but doesn't in Windows 8? (not tested in anything other) Also, is it close to working correctly in Linux as well?

Thanks in advance

Richard

function TfrmMain.GetDaysUptime: integer;
var
   TickCount: variant;
   mySeconds: variant;
   dys,hrs,min,sec : variant;
begin
  TickCount := LclIntf.GetTickCount;
  mySeconds := TickCount Div 1000;
  hrs := (mySeconds Div 60) Div 60;
  mySeconds := mySeconds - (hrs * 60 * 60);
  min := mySeconds Div 60;
  mySeconds := mySeconds - (min * 60);
  sec := mySeconds;
  if hrs >= 24 then
    dys := hrs Div 24
  else
    dys := 0;
   Result := dys;

end;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20140806/54045e5c/attachment.html>

Reply by email

Sven Barth
to Richard Mace
"Richard Mace" wrote
Hi, Does anyone know why the following code returns the correct days uptime

in XP, but doesn't in Windows 8? (not tested in anything other)

Just in case: you know that Windows 8 does not really shutdown by default, but merely suspends to provide a faster "user experience"? So the result returned by GetTickCount will not be what you might expect. Also on Unix systems it won't work as GetTickCount is linked up with a date/time based function there.

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20140806/2494606c/attachment.html>

Reply by email

Richard Mace
to Sven Barth: in XP, but doesn't in Windows 8? (not tested in anything other) Just in case: you know…

Ah, that's interesting.
Even if you actually choose Shutdown from the menu? Richard

"Sven Barth" wrote 22 lines
Am 06.08.2014 07:50 schrieb "Richard Mace" : > > Hi, > Does anyone know why the following code returns the correct days uptime in XP, but doesn't in Windows 8? (not tested in anything other) Just in case: you know that Windows 8 does not really shutdown by default, but merely suspends to provide a faster "user experience"? So the result returned by GetTickCount will not be what you might expect. Also on Unix systems it won't work as GetTickCount is linked up with a date/time based function there. Regards, Sven -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20140806/5cf872cf/attachment.html>

Reply by email

Sven Barth
to Richard Mace
"Richard Mace" wrote
Ah, that's interesting. Even if you actually choose Shutdown from the menu?

Especially then. AFAIK a reboot triggers a full shutdown (with restart of course) and there might also be another possibility for a clean shutdown, but I don't remember that...

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20140806/3701a0d3/attachment.html>

Reply by email

Richard Mace
to Sven Barth

Interesting. I was sure that it was fully shutting down. I'll test the code after a fresh reboot
Richard

"Sven Barth" wrote 19 lines
Am 06.08.2014 11:28 schrieb "Richard Mace" : > > Ah, that's interesting. > Even if you actually choose Shutdown from the menu? Especially then. AFAIK a reboot triggers a full shutdown (with restart of course) and there might also be another possibility for a clean shutdown, but I don't remember that... Regards, Sven -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20140806/7f8eab39/attachment.html>

Reply by email

Richard Mace
to Sven Barth: Especially then. AFAIK a reboot triggers a full shutdown (with restart of course) and…

Hi Sven,
I'm amazed! Sure enough, if I choose "restart" the uptime reads 0 days, and yet, shutdown doesn't actually shut it down!
Crazy!
Richard

Sven Barth wrote 20 lines
Am 06.08.2014 11:28 schrieb "Richard Mace" : > > Ah, that's interesting. > Even if you actually choose Shutdown from the menu? Especially then. AFAIK a reboot triggers a full shutdown (with restart of course) and there might also be another possibility for a clean shutdown, but I don't remember that... Regards, Sven -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20140806/0846c9c2/attachment.html>

Reply by email

Sven Barth
to Richard Mace
Richard Mace wrote
Hi Sven, I'm amazed! Sure enough, if I choose "restart" the uptime reads 0 days, and yet, shutdown doesn't actually shut it down!

Yes, Windows only shuts down the user session till only the bare core of the OS is remaining and then goes to hibernate. This allows for a much faster resume than full shutdown. So they say... ;)

Here is a link which explains how to achieve a full shut down: http://www.howtohaven.com/system/how-to-shutdown-windows-8.shtml (after the section title "How to Really Shut Down Windows 8")

Regards,
Sven

Reply by email

Kovács László
to Sven Barth

This is offtopic now, not related to lazarus, but better be aware. That behavior of Win8 caused data loss for me.
Once I needed to copy hundreds of GB-s, so removed the HDD from a win8 machine after thinking it has shut down.
Placing that HDD in my Win7 desktop and right after start it ran chkdsk, because it detected something broken because of an unclean shutdown. I could skip this chkdsk if I knew about, but after switching on the win7 machine my attention was at a different point. Just noticed the running chkdsk when it almost finished. Most of the file were gone...
Thanks God, testdisk was able to restore most of the lost files, but not all.

Thanks for reading.

Regards
Laszlo Kovacs

------ Az eredeti ?zenet ------
Felad?: "Sven Barth"
C?mzett:
Elk?ld?tt elemek: 2014.08.06. 22:14:10
T?rgy Re: [Lazarus] Obtaining uptime

Show quoted text 23 lines
On 06.08.2014 21:15, Richard Mace wrote: >Hi Sven, >I'm amazed! Sure enough, if I choose "restart" the uptime reads 0 >days, >and yet, shutdown doesn't actually shut it down! Yes, Windows only shuts down the user session till only the bare core of the OS is remaining and then goes to hibernate. This allows for a much faster resume than full shutdown. So they say... ;) Here is a link which explains how to achieve a full shut down: http://www.howtohaven.com/system/how-to-shutdown-windows-8.shtml (after the section title "How to Really Shut Down Windows 8") Regards, Sven -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Michael Schnell
to Sven Barth: in XP, but doesn't in Windows 8? (not tested in anything other) Just in case: you know…
Sven Barth wrote
Just in case: you know that Windows 8 does not really shutdown by default, but merely suspends to provide a faster "user experience"?

(Off Topic: )

Are they crazy ?

If you have an SSD, again and again rewriting the huge hibernation file will kill the device.

So if there is no user-friendly option to deselect this queer option the users should be bashing them ....

-Michael

Reply by email

Sven Barth
to Michael Schnell
"Michael Schnell" wrote 5 lines
On 08/06/2014 08:05 AM, Sven Barth wrote: > > > Just in case: you know that Windows 8 does not really shutdown by

default, but merely suspends to provide a faster "user experience"?

Show quoted text 6 lines
> (Off Topic: ) Are they crazy ? If you have an SSD, again and again rewriting the huge hibernation file

will kill the device.

Did you read what I wrote later on? The system shuts down most of the system and thus only needs to save the core OS (which is much smaller) and not the whole RAM.

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20140807/73206dde/attachment.html>

Reply by email

Frederic Da Vitoria
to Michael Schnell: (Off Topic: ) Are they crazy ? If you have an SSD, again and again rewriting the huge…

2014-08-07 10:22 GMT+02:00 Michael Schnell :

Show quoted text 15 lines
On 08/06/2014 08:05 AM, Sven Barth wrote: > > Just in case: you know that Windows 8 does not really shutdown by > default, but merely suspends to provide a faster "user experience"? > > (Off Topic: ) Are they crazy ? If you have an SSD, again and again rewriting the huge hibernation file will kill the device. So if there is no user-friendly option to deselect this queer option the users should be bashing them ....

I thought that SSD lifespan was more influenced by the number of writes at the same place than by the volume of writes. I mean : if you overwrite the same file each second the SSD would fail in less time than if you wrote a different file in a different place each second. But I could be wrong.

Frederic Da Vitoria (davitof) Membre de l'April - ? promouvoir et d?fendre le logiciel libre ? - http://www.april.org -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20140807/cf8dcfb1/attachment.html>

Reply by email

Marco van de Voort
to Sven Barth: Especially then. AFAIK a reboot triggers a full shutdown (with restart of course) and…
Sven Barth wrote 8 lines
Am 06.08.2014 11:28 schrieb "Richard Mace" : > > Ah, that's interesting. > Even if you actually choose Shutdown from the menu? Especially then. AFAIK a reboot triggers a full shutdown (with restart of course) and there might also be another possibility for a clean shutdown, but I don't remember that...

Yes, go to power options -> what buttons do and turn off "fast startup".

This is also needed if you have older drivers, since not all support this (usually the same as the ones that don't support hibernation).

At work we thus turn it off by default.

Reply by email

Marco van de Voort
to Michael Schnell: (Off Topic: ) Are they crazy ? If you have an SSD, again and again rewriting the huge…
Michael Schnell wrote 11 lines
On 08/06/2014 08:05 AM, Sven Barth wrote: > > Just in case: you know that Windows 8 does not really shutdown by > default, but merely suspends to provide a faster "user experience"? > (Off Topic: ) Are they crazy ? If you have an SSD, again and again rewriting the huge hibernation file will kill the device.

That's the whole idea to not do that. Only when the system changes the image is redone. Keep in mind it doesn't save the current state (since you are shutting down), so only the last boot state is saved, usually the one from last patch tuesday.

(that being said, I use hibernation on SSD devices without much problems. Usually they are specified as writing the whole space several times a day)

Reply by email

Reinier Olislagers
to Marco van de Voort: Yes, go to power options -> what buttons do and turn off "fast startup". This is also…
Marco van de Voort wrote 17 lines
On Wed, Aug 06, 2014 at 11:52:48AM +0200, Sven Barth wrote: > Am 06.08.2014 11:28 schrieb "Richard Mace" : >> >> Ah, that's interesting. >> Even if you actually choose Shutdown from the menu? > > Especially then. AFAIK a reboot triggers a full shutdown (with restart of > course) and there might also be another possibility for a clean shutdown, > but I don't remember that... Yes, go to power options -> what buttons do and turn off "fast startup". This is also needed if you have older drivers, since not all support this (usually the same as the ones that don't support hibernation). At work we thus turn it off by default.

Wow.

Reply by email

Marco van de Voort
to Reinier Olislagers
Reinier Olislagers wrote 8 lines
> Yes, go to power options -> what buttons do and turn off "fast startup". > > This is also needed if you have older drivers, since not all support this > (usually the same as the ones that don't support hibernation). > > At work we thus turn it off by default. Wow.

Don't get me wrong. It is generally a good feature, but not for everything, and keep in mind that "industrial" equipment is often a positive sounding synonym for "old".

Reply by email