Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Get Time C#(read only memory) [modified]

Get Time C#(read only memory) [modified]

Scheduled Pinned Locked Moved C#
csharpperformancequestion
15 Posts 8 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    arun_pk
    wrote on last edited by
    #1

    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

    J R OriginalGriffO 3 Replies Last reply
    0
    • A arun_pk

      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

      J Offline
      J Offline
      JF2015
      wrote on last edited by
      #2

      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.

      A 1 Reply Last reply
      0
      • J JF2015

        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.

        A Offline
        A Offline
        arun_pk
        wrote on last edited by
        #3

        thanks a lot for the reply i am sorry i for got to update that my application don't have an internet connection

        J K 2 Replies Last reply
        0
        • A arun_pk

          thanks a lot for the reply i am sorry i for got to update that my application don't have an internet connection

          J Offline
          J Offline
          JF2015
          wrote on last edited by
          #4

          If you don't have internet connection, then you won't have a chance of detecting a changed system time. At least I can't think of any reasonable way. Sorry.

          1 Reply Last reply
          0
          • A arun_pk

            thanks a lot for the reply i am sorry i for got to update that my application don't have an internet connection

            K Offline
            K Offline
            Keith Barrow
            wrote on last edited by
            #5

            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[^]

            A B 2 Replies Last reply
            0
            • K Keith Barrow

              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[^]

              A Offline
              A Offline
              arun_pk
              wrote on last edited by
              #6

              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

              L K P 4 Replies Last reply
              0
              • A arun_pk

                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

                R Offline
                R Offline
                Rob Philpott
                wrote on last edited by
                #7

                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.

                A 1 Reply Last reply
                0
                • R 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.

                  A Offline
                  A Offline
                  arun_pk
                  wrote on last edited by
                  #8

                  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 :( :(

                  R 1 Reply Last reply
                  0
                  • A arun_pk

                    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 :( :(

                    R Offline
                    R Offline
                    Rob Philpott
                    wrote on last edited by
                    #9

                    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.

                    1 Reply Last reply
                    0
                    • A arun_pk

                      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

                      OriginalGriffO Offline
                      OriginalGriffO Offline
                      OriginalGriff
                      wrote on last edited by
                      #10

                      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.

                      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                      "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                      1 Reply Last reply
                      0
                      • A arun_pk

                        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

                        L Offline
                        L Offline
                        Lost User
                        wrote on last edited by
                        #11

                        Tut, tut, you are trying to break the rules. :(

                        Just say 'NO' to evaluated arguments for diadic functions! Ash

                        1 Reply Last reply
                        0
                        • A arun_pk

                          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

                          K Offline
                          K Offline
                          Keith Barrow
                          wrote on last edited by
                          #12

                          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:

                          1. It could "calls home" to get the time off a server as well where an Internet connection is present?
                          2. 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).
                          3. 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[^]

                          1 Reply Last reply
                          0
                          • A arun_pk

                            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

                            P Offline
                            P Offline
                            Pete OHanlon
                            wrote on last edited by
                            #13

                            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

                            My blog | My articles | MoXAML PowerToys | Onyx

                            1 Reply Last reply
                            0
                            • A arun_pk

                              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

                              L Offline
                              L Offline
                              Lost User
                              wrote on last edited by
                              #14

                              Buy the software, sounds like it will be cheaper.

                              Join the cool kids - Come fold with us[^]

                              1 Reply Last reply
                              0
                              • K Keith Barrow

                                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[^]

                                B Offline
                                B Offline
                                Bernhard Hiller
                                wrote on last edited by
                                #15

                                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.

                                1 Reply Last reply
                                0
                                Reply
                                • Reply as topic
                                Log in to reply
                                • Oldest to Newest
                                • Newest to Oldest
                                • Most Votes


                                • Login

                                • Don't have an account? Register

                                • Login or register to search.
                                • First post
                                  Last post
                                0
                                • Categories
                                • Recent
                                • Tags
                                • Popular
                                • World
                                • Users
                                • Groups