Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Delphi System Reboot Counter (https://www.delphipraxis.net/200366-system-reboot-counter.html)

SlpLow 14. Apr 2019 04:34

System Reboot Counter
 
Hello,
How to create a system reboot counter in the registry?

Delphi.Narium 14. Apr 2019 10:15

AW: System Reboot Counter
 
https://superuser.com/questions/2780...n-has-rebooted

SlpLow 14. Apr 2019 11:47

AW: System Reboot Counter
 
Zitat:

Zitat von Delphi.Narium (Beitrag 1430277)

Thank you, not that.
Need a counter after running my program

HolgerX 14. Apr 2019 15:36

AW: System Reboot Counter
 
Hmm..

When I have unstand it right, you have 2 options:

1.)
Create your own form with a timer and show the counter there.
At the end you execute the shutdown...
(using: https://docs.microsoft.com/en-us/win...down-functions)


2.)
Use then 'shutdown' batch-command:
https://www.cnet.com/how-to/put-a-sh...-this-command/

Both have a timer until shutdown...
Non off them have a regitry entry..

SlpLow 14. Apr 2019 21:15

AW: System Reboot Counter
 
Zitat:

Zitat von HolgerX (Beitrag 1430287)
When I have unstand it right, you have 2 options: ..

Hi,
need to.

1. Run my program - Launcher
2. Run another application - CreateProcess
3. Skip two system reboots - ???
4. Restarting the my program from - RunOnce

DieDolly 14. Apr 2019 21:17

AW: System Reboot Counter
 
Zitat:

3. Skip two system reboots - ???
As far as I know since Windows XP you can't skip system reboots anymore. Once windows is rebooting it's shuttong down all running programs. Using Windows XP it was possible to skip the reboot until your programs sends the OK.

SlpLow 14. Apr 2019 21:26

AW: System Reboot Counter
 
Zitat:

Zitat von DieDolly (Beitrag 1430294)
Zitat:

3. Skip two system reboots - ???
As far as I know since Windows XP you can't skip system reboots anymore. Once windows is rebooting it's shuttong down all running programs. Using Windows XP it was possible to skip the reboot until your programs sends the OK.

Sorry!

2* - Need to skip the auto start of my program

DieDolly 14. Apr 2019 21:38

AW: System Reboot Counter
 
You can not skip the auto start of your program. You need to get it out of the registry first.
Would be nice to see longer sentences written by yourself. Maybe people understand better what you want to achieve then.

SlpLow 15. Apr 2019 03:23

AW: System Reboot Counter
 
Zitat:

Zitat von DieDolly (Beitrag 1430296)
You can not skip the auto start of your program. You need to get it out of the registry first.
Would be nice to see longer sentences written by yourself. Maybe people understand better what you want to achieve then.

Launched from my program, the process makes two restart. It is necessary to register itself in the registry after these reboots.

HolgerX 15. Apr 2019 08:01

AW: System Reboot Counter
 
Hmm..

Could this be your option for blocking the reboot:

https://docs.microsoft.com/en-us/win...ckreasoncreate

Der schöne Günther 15. Apr 2019 08:20

AW: System Reboot Counter
 
He does not want to block reboots. He has his application already registered in auto start, but does not want his application to run for the next two times the system boots.

Trying to get your application out of the "RunOnce" thing and then back in is the wrong approach, in my opinion. Why don't you just keep track of the reboot counter when your setup (or whatever it is) starts, and when your application launches, you compare if the boot count is greater than
Delphi-Quellcode:
saved_bootcount + 2
. If not, just exit your application.

dummzeuch 15. Apr 2019 08:20

AW: System Reboot Counter
 
OK, as far as I understand you want your program to execute an action on every second reboot.

This is how I would implement this:

* Add your program to the autostart.
* When it starts, read the reboot counter mentioned above. Compare it to your own registry entry (under HKCU\Software\<your company>\<your program>).
* If your entry does not exist, assume that this is the first time your program was started, execute the action.
* If your entry exists, compare its value to the reboot counter. If the difference is <=1 skip the action, otherwise excute the action.
* Write the reboot counter to your registry entry and exit.

Note that this will only work if it is always the same user who works on that computer. Otherwise you will need keep your own counter somewhere else but HKCU, because that entry is user dependent.

Moombas 15. Apr 2019 09:58

AW: System Reboot Counter
 
Zitat:

Zitat von dummzeuch (Beitrag 1430305)
OK, as far as I understand you want your program to execute an action on every second reboot.

This is how I would implement this:

* Add your program to the autostart.
* When it starts, read the reboot counter mentioned above. Compare it to your own registry entry (under HKCU\Software\<your company>\<your program>).
* If your entry does not exist, assume that this is the first time your program was started, execute the action.
* If your entry exists, compare its value to the reboot counter. If the difference is <=1 skip the action, otherwise excute the action.
* Write the reboot counter to your registry entry and exit.

Note that this will only work if it is always the same user who works on that computer. Otherwise you will need keep your own counter somewhere else but HKCU, because that entry is user dependent.

Another "solution" would be to write it in a file (e.g. ini file in working directory). That would be user unindependent. Maybe create it when needed, and delete it when ready.

SlpLow 15. Apr 2019 17:19

AW: System Reboot Counter
 
Thank you very much! Now I have no doubt in the logic of performing the task.

Sherlock 16. Apr 2019 07:34

AW: System Reboot Counter
 
And on a side note, consider visiting our English speaking sister site https://en.delphipraxis.net/
Not that there is anything wrong with posting in english here, but you might get faster responses, as it is international and users there come from all timezones.

Sherlock


Alle Zeitangaben in WEZ +1. Es ist jetzt 11:45 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz