Thema: Delphi System Reboot Counter

Einzelnen Beitrag anzeigen

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, 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