首页 > 解决方案 > How to determine if the PC has been rebooted since my program's last run?

问题描述

The title says it all.

What is the best way to determine if the PC has been rebooted since my program's last run?

Context: C# - Win XP and on

A piece of hardware (PCIe board) that I'm configuring requires the settings to only be sent once per power cycle but users may close and open the program multiple times before power cycling the PC.

I'm thinking I need some sort of a global reference that my program starts/sets while starting then it can check if said global reference is running/true at each start up and act accordingly.

Ideas? Suggestions?

标签: c#windowsboot

解决方案


有关如何获取上次启动时间的信息,请参阅如何知道 Windows 何时启动或关闭。

您可以将启动时间写入文件。启动程序时,您可以检查保存的值是否与当前值匹配,并在需要时使用新值更新文件。

另请参阅获取上次重启时间


推荐阅读