c# - 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?
解决方案
有关如何获取上次启动时间的信息,请参阅如何知道 Windows 何时启动或关闭。
您可以将启动时间写入文件。启动程序时,您可以检查保存的值是否与当前值匹配,并在需要时使用新值更新文件。
另请参阅获取上次重启时间
推荐阅读
- php - 获取一个日期并在午夜之后显示它大约 2 小时
- dart - Flutter 中的首字母大写
- sql-server - 服务器关闭时如何处理 SQL Server 代理作业
- ruby - 如何运行 cronjobs 和 rackup
- amazon-web-services - 如何在 AWS 中下载我的公钥(密钥对)?
- reactjs - 尝试导入错误:“模型”未从“../模块”导出
- java - 单引号内未替换命名参数
- cuda - openACC 例程中的 cuSPARSE 库调用
- ios - 单个 BLE 中央可以通过低功耗蓝牙连接多个 BLE 外设吗?
- r - 在ggplot中添加手动比例时如何修复错误?