You don't do it the way you want to do. It wouldn't work.
You check with an authoritative internet time server or something similar (or you put up a server of your with a web service that return the current time). If you don't know how to do it, you simply check http://tycho.usno.navy.mil/cgi-bin/timer.pl
I'll add that you can read here Prevent time-based copy protection circumvention? if you don't trust me.
I'll tell another strategy. I'm not sure it can work. It has many many problems (it runs on my machine, but I haven't tested it anywhere). It's slow (you should run it in its thread and if there is an error cause the thread to exit the program). I don't know if it's compatible. I don't know if low level users can run it.
It looks at the list of upgrades for Windows and takes the most recent one date. If the user doesn't ever updates his windows, he will trick it.
Add a reference to C:\Windows\System32\wuapi.dll
. It will generate an "interop" dll and add a reference to it.
using WUApiLib;
UpdateSession uSession = new UpdateSession();
IUpdateSearcher uSearcher = uSession.CreateUpdateSearcher();
uSearcher.Online = false;
try
{
ISearchResult sResult = uSearcher.Search("IsInstalled=1 OR IsInstalled=0");
// This one!!!!
var maxTime = sResult.Updates.OfType<IUpdate>().Max(p => p.LastDeploymentChangeTime);
}
catch (Exception ex)
{
Console.WriteLine("Something went wrong: " + ex.Message);
}
Oh... I was supposing you where using C# :-) If you are using C++ you can convert the code. The next time you'll learn to put the tag of the language.