Get Time C#(read only memory) [modified]
-
How can i get the actual time in c# which will not get change even after we change system clock *** application /pc were no internet connection
modified on Thursday, December 30, 2010 7:17 AM
-
Have a look here: http://nickstips.wordpress.com/2010/02/12/c-get-nist-internet-time/[^] You will need to get the time from an internet time server. Otherwise you can't be sure if the time of the local pc was changed.
-
thanks a lot for the reply i am sorry i for got to update that my application don't have an internet connection
-
thanks a lot for the reply i am sorry i for got to update that my application don't have an internet connection
arun_pk wrote:
i am sorry i for got to update that my application don't have an internet connection
As far as I'm aware, your requirement is impossible: You either use the system clock, or use an external one. If an Internet clock isn't good, you could use one of the following: This (it works in Europe) that syncs with the atomic clock signal: http://www.lindy.co.uk/usb-precision-clock/20984.html[^]or http://www.atomicclockrugbymsf.co.uk/ntp-time-server/atomic-clock.html[^] Or You could also sync with the clock in a connected GPS system, I think these need to be accurate
Sort of a cross between Lawrence of Arabia and Dilbert.[^]
-Or-
A Dead ringer for Kate Winslett[^] -
arun_pk wrote:
i am sorry i for got to update that my application don't have an internet connection
As far as I'm aware, your requirement is impossible: You either use the system clock, or use an external one. If an Internet clock isn't good, you could use one of the following: This (it works in Europe) that syncs with the atomic clock signal: http://www.lindy.co.uk/usb-precision-clock/20984.html[^]or http://www.atomicclockrugbymsf.co.uk/ntp-time-server/atomic-clock.html[^] Or You could also sync with the clock in a connected GPS system, I think these need to be accurate
Sort of a cross between Lawrence of Arabia and Dilbert.[^]
-Or-
A Dead ringer for Kate Winslett[^] -
How can i get the actual time in c# which will not get change even after we change system clock *** application /pc were no internet connection
modified on Thursday, December 30, 2010 7:17 AM
Well, if the clock on the PC is wrong and you have no internet connection, its going to be hard to know what the time is. Impossible perhaps. What you do have is
Environment.TickCount
, which is the number of very small 'ticks' (order of tens of nanoseconds I think) since start up. If you know the time is correct when you start up, you can use this and a bit of maths to keep telling the correct time even if the clock changes.Regards, Rob Philpott.
-
Well, if the clock on the PC is wrong and you have no internet connection, its going to be hard to know what the time is. Impossible perhaps. What you do have is
Environment.TickCount
, which is the number of very small 'ticks' (order of tens of nanoseconds I think) since start up. If you know the time is correct when you start up, you can use this and a bit of maths to keep telling the correct time even if the clock changes.Regards, Rob Philpott.
-
Hello Rob will this workout if i dont run the system regularly? i want to implement a trial version kinda thing for thirty days :( were i dont have internet :( :(
No, it won't I'm afraid. That's a tricky problem but have a look around and I'm sure you'll find some discussion on it on the net. Instead of a 30 day trial, would being able to only run the app a certain number of times be an alternative?
Regards, Rob Philpott.
-
How can i get the actual time in c# which will not get change even after we change system clock *** application /pc were no internet connection
modified on Thursday, December 30, 2010 7:17 AM
Without an external clock source, which cannot be altered by the user, you can't do this with complete reliability. However, you can set up a service (which must be running in order to use your app) which monitors the current time, and records it. If it is changed backwards, then it can cause a "validation failure" on your app. This can't catch every thing, and it has to be carefully done (avoid Summer time changes causing a problem, etc.) but it can be reasonably effective. Other options: 1) Run time limited to n hours. After your app has executed for n hours, refuse to start. This tends to be more reliable (and more friendly) as people know where they are. 2) Function limited version. To be honest, any trial protection is a pain for honest people, and a challenge for the dishonest. It generally isn't too difficult to circumvent and you can spend more on adding it to your app than you save in lost sales...
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
-
thanks for reply i hope there should be some way other than using external clock.. coz applications like photoshop and all runs only 30 days .. even if we change the system time
-
thanks for reply i hope there should be some way other than using external clock.. coz applications like photoshop and all runs only 30 days .. even if we change the system time
The photoshop will store the latest system date it has run, if you wind back the clock before windows starts, my guess is you get a free copy of photoshop :-) There are a few things Photoshop possibly does to help with the problem:
- It could "calls home" to get the time off a server as well where an Internet connection is present?
- It might keep track of how long it has been running, to make sure it doesn't exceed the limit (e.g. 30 days continuous execution).
- Some cleverer algorithm, where it keeps track of when it was used, if the current date time is before the latest used date it does something
I know I've fallen foul of point three, when doing some system date specific testing: the software thought I was spoofing the date, so it ended the license immediately.
Sort of a cross between Lawrence of Arabia and Dilbert.[^]
-Or-
A Dead ringer for Kate Winslett[^] -
thanks for reply i hope there should be some way other than using external clock.. coz applications like photoshop and all runs only 30 days .. even if we change the system time
They use rather more sophisticated algorithms, and detect such things as the system clock having been wound back; there are things that can be done to check to see that the time is different to what is should be.
I'm not a stalker, I just know things. Oh by the way, you're out of milk.
Forgive your enemies - it messes with their heads
-
thanks for reply i hope there should be some way other than using external clock.. coz applications like photoshop and all runs only 30 days .. even if we change the system time
-
arun_pk wrote:
i am sorry i for got to update that my application don't have an internet connection
As far as I'm aware, your requirement is impossible: You either use the system clock, or use an external one. If an Internet clock isn't good, you could use one of the following: This (it works in Europe) that syncs with the atomic clock signal: http://www.lindy.co.uk/usb-precision-clock/20984.html[^]or http://www.atomicclockrugbymsf.co.uk/ntp-time-server/atomic-clock.html[^] Or You could also sync with the clock in a connected GPS system, I think these need to be accurate
Sort of a cross between Lawrence of Arabia and Dilbert.[^]
-Or-
A Dead ringer for Kate Winslett[^]Keith Barrow wrote:
You could also sync with the clock in a connected GPS system, I think these need to be accurate
Not necessarily, see my post to the lounge (http://www.codeproject.com/Lounge.aspx?msg=3558840[^]) which shows real data proving the inaccurateness of a GPS unit clock.