Click here to Skip to main content
15,879,096 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm writing a program right now which requires a full system restart before certain functionality can be used. I have looked on Google and so far the best way that I have found to detect a system restart/or lack of, is to use the Registry key RunOnce to add another key as an indication, but this also runs on log-in's which isn't useful for me. How can I detect whether the computer has been restarted or not using VB.net? The target machine of this program is solely Windows 7.

I also would prefer to not use any "System Up-Time" solutions to avoid daylight-savings, time zone change, or bois reset issues.
Posted
Updated 20-Jun-10 16:33pm
v2

1 solution

For what you're looking for you won't be able to find a single-gun solution.

You'll need to leverage RunOnce and System Boot Time to be effective here (and I'm not sure a dubious user wouldn't be able to bypass these anyways).

System boot time is not reset on logon. If you're using the performance metric (instead of Environment.TickCount) you don't run into the 25 day (or so) problem with running out of ints.

Mash these two together to come up with the solution, perhaps even creating another RunOnce if the System Boot Time metric you record doesn't jive with your expectations.

Cheers.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900