I am building Win32 application. My requirement is to expire this application on a particular date let say for e.g. on 31 december, 2008. If i use system's local time then user will be able to run it by changing its date/time.
So is there any way to get global time in my VC application. Please help me out in this situation.
If client PC is connected to internet then you can ask one of the many time servers for the current time. Otherwise as far as I know there is no way to find the correct time locally. May I ask why you need to do so. Are you trying to build a demo application which expires after a number of days. In that case you should store the time of the installation somewhere in the user PC and check against it.
Thanks for your reply. I also thought about the suggestion for getting global time from server till PC is connected to Internet that you have mentioned. But that's not my requirement. what could be the other way to do so?? As I told you that i need to expire it on particular date. Your suggestion would work if i need to expire it after number of days from its installation.
Please help me out if you still have some suggestions. by the way thanks again for you reply.
As far as I know there is no way to determine the correct time irrespective of the time user has set in the machine. Actually if you think about it there is no such thing as correct time. In Singapore the current time is 15:15 07-11-08, in India it is 12:45 07-11-08 but in Los Angeles it is 11:15 PM on 06-11-08. So which one will you choose?
I didn't get you in your previous reply. If you are asking what i am trying to accomplish is clear. I want to expire my application on particular date. but i can't use local time/date to check it as user may change its local time/date. That's why i am thinking of some other way.
If that is the goal then may I ask why do you want you application to suddenly stop working for every user. What purpose the purpose of this?
There is no suggestion I can give you for finding time, even if you assume that you want time in a particular time zone. As far as I know there is no way for a standalone computer to determine current time. In fact no device can have such capability because time is not absolute.
My suggestion is to follow what beko said. In addition to that you can mark it as expired once the expiry date reached. After that you should not allow the application to continue working even if the date is changed back.