Times at which a local computer was turned on
-
- Addict
- Posts: 4519
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
Times at which a local computer was turned on
Hi all!
For instance the tool TurnedOnTimesView by NirSoft provides detailed information about time ranges when a computer was turned on. It does do so by reading the system event log.
How can I get this information with a PureBasic program? I only want to get say the last 3 times when my local PC was turned on.
For instance the tool TurnedOnTimesView by NirSoft provides detailed information about time ranges when a computer was turned on. It does do so by reading the system event log.
How can I get this information with a PureBasic program? I only want to get say the last 3 times when my local PC was turned on.
Re: Times at which a local computer was turned on
Only Window ...
MSDN
https://docs.microsoft.com/en-us/window ... ttickcount
https://docs.microsoft.com/en-us/window ... ickcount64
MSDN
https://docs.microsoft.com/en-us/window ... ttickcount
https://docs.microsoft.com/en-us/window ... ickcount64
Code: Select all
Import "" ; Kernel32.lib
GetTickCount64()
EndImport
;cnt.i = (GetTickCount_() / 1000) & $FFFFFFFF
cnt.q = (GetTickCount64() / 1000)
days = cnt / 86400
cnt = cnt % 86400
hours = cnt / 3600
cnt = cnt % 3600
minutes = cnt / 60
cnt = cnt % 60
seconds = cnt
Debug "" + days + "d " + hours + "h " + minutes + "m " + seconds + "s "
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Re: Times at which a local computer was turned on
We need someone to update this -> https://www.purebasic.fr/english/viewto ... 69#p552969 Then we can parse it for the last 3 power on/off times.Little John wrote:How can I get this information with a PureBasic program?
-
- Addict
- Posts: 4519
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
Re: Times at which a local computer was turned on
Yes, currently I need only a solution on Windows ( that's why I posted this question in the "Windows" subforum. )mk-soft wrote:Only Window ...
MSDN
https://docs.microsoft.com/en-us/window ... ttickcount
https://docs.microsoft.com/en-us/window ... ickcount64
However, GetTickCount_() does not provide the information I am looking for.
That seems to put me on the right track, thank you!BarryG wrote:We need someone to update this -> https://www.purebasic.fr/english/viewto ... 69#p552969 Then we can parse it for the last 3 power on/off times.
Re: Times at which a local computer was turned on
Code: Select all
Import "" ; Kernel32.lib
GetTickCount64()
EndImport
;cnt.i = (GetTickCount_() / 1000) & $FFFFFFFF
cnt.q = (GetTickCount64() / 1000)
TurnOn = Date() - (GetTickCount64() / 1000)
Debug FormatDate("Computer turn on: %YYYY-%MM-%DD %HH:%II:%SS", TurnOn)
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
-
- Addict
- Posts: 4519
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
Re: Times at which a local computer was turned on
*Sigh*mk-soft wrote:Code: Select all
Import "" ; Kernel32.lib GetTickCount64() EndImport ;cnt.i = (GetTickCount_() / 1000) & $FFFFFFFF cnt.q = (GetTickCount64() / 1000) TurnOn = Date() - (GetTickCount64() / 1000) Debug FormatDate("Computer turn on: %YYYY-%MM-%DD %HH:%II:%SS", TurnOn)
Please read before "replying"!
If you want to know what I am looking for, read my first post in this thread thoroughly.Little John wrote:However, GetTickCount_() does not provide the information I am looking for.
Re: Times at which a local computer was turned on
Sorry,
I thought you wanted to know when the computer was started and then filter the data from date and time.
But I still find my code very helpful
I thought you wanted to know when the computer was started and then filter the data from date and time.
But I still find my code very helpful
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
-
- Enthusiast
- Posts: 224
- Joined: Sat Jul 07, 2018 6:50 pm
Re: Times at which a local computer was turned on
Windows event logs with PB-TurnedOnTimesView based on a few types of events on the event log of Windows
-If you clear your system event log, TurnedOnTimesView will not be able to detect the shutdown/startup times
-On systems prior to Windows Vista, Shutdown Reason, Shutdown Type, and Shutdown Process fields are usually empty
TurnedOnTimesView uses the following events to determine the turn off/turn on times:
EventID 41 (Microsoft-Windows-Kernel-Power): The system has rebooted without cleanly shutting down first. This error could be caused if the system stopped responding, crashed, or lost power unexpectedly.
EventID 42 (Microsoft-Windows-Kernel-Power): The system is entering sleep
EventID 1 (Microsoft-Windows-Power-Troubleshooter): The system has resumed from sleep.
EventID 1074 (USER32): The process xxx has initiated the xxx of computer xxx on behalf of user xxx for the following reason: xxx
EventID 6005 (EventLog): The Event log service was started.
EventID 6006 (EventLog): The Event log service was stopped
-
- Addict
- Posts: 4519
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
Re: Times at which a local computer was turned on
I am glad that I was able to give you the opportunity to post offtopic blah blah and feel helpful.mk-soft wrote:But I still find my code very helpful
Re: Times at which a local computer was turned on
@mk-soft: Since Windows only restarts on reboot, your value shows the time of the last reboot.mk-soft wrote:Sorry,
I thought you wanted to know when the computer was started and then filter the data from date and time.
But I still find my code very helpful
"Daddy, I'll run faster, then it is not so far..."