AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren

System Reboot Counter

Ein Thema von SlpLow · begonnen am 14. Apr 2019 · letzter Beitrag vom 16. Apr 2019
Antwort Antwort
Seite 2 von 2     12
Der schöne Günther
Online

Registriert seit: 6. Mär 2013
6.093 Beiträge
 
Delphi 10 Seattle Enterprise
 
#11

AW: System Reboot Counter

  Alt 15. Apr 2019, 09:20
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 saved_bootcount + 2 . If not, just exit your application.
  Mit Zitat antworten Zitat
Benutzerbild von dummzeuch
dummzeuch

Registriert seit: 11. Aug 2012
Ort: Essen
1.449 Beiträge
 
Delphi 10.2 Tokyo Professional
 
#12

AW: System Reboot Counter

  Alt 15. Apr 2019, 09:20
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.
Thomas Mueller
  Mit Zitat antworten Zitat
Benutzerbild von Moombas
Moombas

Registriert seit: 22. Mär 2017
Ort: bei Flensburg
525 Beiträge
 
FreePascal / Lazarus
 
#13

AW: System Reboot Counter

  Alt 15. Apr 2019, 10:58
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.
Der Weg ist das Ziel aber man sollte auf dem Weg niemals das Ziel aus den Augen verlieren.
  Mit Zitat antworten Zitat
SlpLow

Registriert seit: 4. Nov 2013
28 Beiträge
 
#14

AW: System Reboot Counter

  Alt 15. Apr 2019, 18:19
Thank you very much! Now I have no doubt in the logic of performing the task.
  Mit Zitat antworten Zitat
Benutzerbild von Sherlock
Sherlock

Registriert seit: 10. Jan 2006
Ort: Offenbach
3.753 Beiträge
 
Delphi 11 Alexandria
 
#15

AW: System Reboot Counter

  Alt 16. Apr 2019, 08:34
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
Oliver
Geändert von Sherlock (Morgen um 16:78 Uhr) Grund: Weil ich es kann
  Mit Zitat antworten Zitat
Themen-Optionen Thema durchsuchen
Thema durchsuchen:

Erweiterte Suche
Ansicht

Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 16:21 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