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

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

AW: System Reboot Counter

  Alt 15. Apr 2019, 08: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
dummzeuch

Registriert seit: 11. Aug 2012
Ort: Essen
382 Beiträge
 
Delphi 2007 Professional
 
#12

AW: System Reboot Counter

  Alt 15. Apr 2019, 08: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
141 Beiträge
 
Delphi 10.2 Tokyo Starter
 
#13

AW: System Reboot Counter

  Alt 15. Apr 2019, 09: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, 17: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.247 Beiträge
 
Delphi 10.3 Rio
 
#15

AW: System Reboot Counter

  Alt 16. Apr 2019, 07: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
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 09:53 Uhr.
Powered by vBulletin® Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2019 by Daniel R. Wolf