English 中文(简体)
How Can I Check To See If the User Set His Clock Back?
原标题:

In my desktop program, I want to check that to see if the user has set his clock back.

To do so, I compare the timestamp of certain Operating System files to the current computer date. If any are after what the computer thinks is the current date, then he must have set his clock back.

For Windows XP, I have been using such files as:

c:win386.swp
c:windowsuser.dat
and several others.

Two questions:

  1. Is this a decent way to do this, or is there something better?

  2. (Assuming the answer to 1 is "decent") What would be some good Windows Vista and Windows 7 files to compare with?


Conclusion: Priyank said something obvious that had eluded me: Rather than using any system files, the easiest and simplest way might be to just use the timestamp of your program itself. After all, the date it was installed is exactly the date you want your trial to start from.

As it turns out, your answers and my research of other related StackOverflow questions and mentioned articles has led me to decide on a much simpler scheme. My trial users already have to get a key to use the trial. I ve got the date registered embedded into the key. I really don t have to check for setting the clock back. Instead I can just seee if the current time is between the date registered and the date registered plus n days.

If they want to go to the trouble of getting around that scheme, then let them. I agree that those people wouldn t pay anyway. Make your program something worthwhile that people enjoy and want to use and most will pay.

最佳回答

Windows files will be always have earlier date, the best is to check the creation or modified date of your program with the system date. Or any time your program quit make sure to note the timestamp and compare it with the next time you start your program, and there is always NTP: http://en.wikipedia.org/wiki/Network_Time_Protocol

问题回答

a better way to do that IMHO would be to store the current timestamp in registry the first time your program is ran and then compare that with the current timestamp on next run and update the timestamp if everything is OK.

This is not a direct answer, just to offer some opinion and references. Too long for me to add as comment.

If the purpose is to create a time-limited software for demo/trial use, we need to find a balance between how much you go about implementing it and the tendency for users to hack pass it.

I ve often tell people, if your software attracts hackers, it s probably something useful/good. No point protecting a software which no one finds useful.

Anyway, the philosophical talk aside, below are a couple good reads about this topic:

How to Implement time-limited trial on Joel s Forum
Time limited trial and Windows Certification on SO
Need Advice on Implementing a Time-limited Trial on SO

An option would be to get the date from a web service or time server. The problem here is that this only works if there is internet connection available, so this would be just a complementary method for a more safe one.

Windows provides APIs for notification of system time changes. One e.g. is the sysinfo.ocx activex control provided here.





相关问题
Why running a service as Local System is bad on windows?

I am trying to find out the difference between difference service account types. I tumbled upon this question. The answer was because it has powerful access to local resources, and Network Service ...

Programmatically detect Windows cluster configuration?

Does anyone know how to programatically detect that a Windows server is part of a cluster? Further, is it possible to detect that the server is the active or passive node? [Edit] And detect it from ...

get file icon for Outlook appointment (.msg)

I ve read Get File Icon used by Shell and the other similar posts - and already use SHFileInfo to get the associated icon for any given extension, and that works great. However, Outlook uses ".msg" ...

Identifying idle state on a windows machine

I know about the GetLastInputInfo method but that would only give me the duration since last user input - keyboard or mouse. If a user input was last received 10 minutes ago, that wouldn t mean the ...

Terminating a thread gracefully not using TerminateThread()

My application creates a thread and that runs in the background all the time. I can only terminate the thread manually, not from within the thread callback function. At the moment I am using ...

热门标签