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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. how to put a timer counter in my software that counts starting from the day installed?

how to put a timer counter in my software that counts starting from the day installed?

Scheduled Pinned Locked Moved C#
helpquestioncsharptutorialannouncement
11 Posts 5 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.
  • C CoderForEver

    Hey my friends ... I have one application done in C# .. but i want to give it for my customers as a trial version (I want it to count from the day it installed up to 30 days) ... But if i use DateAndTime class ... I think if they change the date and time ... so that i can be faked .... can any body help me with this problem .... or how can i get the real date even if they change it ... i.e like other softwares do ... just count from the day it is installed .... Thank you a lot

    P Offline
    P Offline
    PIEBALDconsult
    wrote on last edited by
    #2

    Any or all of: 0) I wouldn't bother. 1) Store the date and time of install or first use and then calculate the elapsed time when it starts up. 2) Have it access a website to get the current date and time rather than use the system clock. 3) Have it access your site (phone home) to determine the date and time and elapsed time.

    A 1 Reply Last reply
    0
    • C CoderForEver

      Hey my friends ... I have one application done in C# .. but i want to give it for my customers as a trial version (I want it to count from the day it installed up to 30 days) ... But if i use DateAndTime class ... I think if they change the date and time ... so that i can be faked .... can any body help me with this problem .... or how can i get the real date even if they change it ... i.e like other softwares do ... just count from the day it is installed .... Thank you a lot

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

      Make a remote call to a server that you control to get the date/time. They can't change the clock on your server.

      [Forum Guidelines]

      C 1 Reply Last reply
      0
      • P PIEBALDconsult

        Any or all of: 0) I wouldn't bother. 1) Store the date and time of install or first use and then calculate the elapsed time when it starts up. 2) Have it access a website to get the current date and time rather than use the system clock. 3) Have it access your site (phone home) to determine the date and time and elapsed time.

        A Offline
        A Offline
        AspDotNetDev
        wrote on last edited by
        #4

        One could also use Environment.TickCount to infer that the time has been changed or the computer has been restarted. If tick count and date are stored together at each use, that can be compared against a later reading. This would not be perfect detection (it would be easy to get around), but it could be used to detect the types of modifications that many users would make. But, it's probably too much work. Doing a simple time check to a remote server would be enough to deter most users from subverting the trial. Also, there are other forms of trials. For example, usage could be limited based on how long the application is left open. This could be more easily tracked than the amount of time it's been installed.

        [Forum Guidelines]

        1 Reply Last reply
        0
        • A AspDotNetDev

          Make a remote call to a server that you control to get the date/time. They can't change the clock on your server.

          [Forum Guidelines]

          C Offline
          C Offline
          CoderForEver
          wrote on last edited by
          #5

          My application is only for 1 PC ... i.e there are no servers or other PC's around there ... There is no internet or cant interact with websites ... it is just for a stand alone computer

          A 1 Reply Last reply
          0
          • C CoderForEver

            My application is only for 1 PC ... i.e there are no servers or other PC's around there ... There is no internet or cant interact with websites ... it is just for a stand alone computer

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

            Then do what I said here and make the trial based on the total number of hours the application has been open.

            [Forum Guidelines]

            L 1 Reply Last reply
            0
            • C CoderForEver

              Hey my friends ... I have one application done in C# .. but i want to give it for my customers as a trial version (I want it to count from the day it installed up to 30 days) ... But if i use DateAndTime class ... I think if they change the date and time ... so that i can be faked .... can any body help me with this problem .... or how can i get the real date even if they change it ... i.e like other softwares do ... just count from the day it is installed .... Thank you a lot

              M Offline
              M Offline
              MumbleB
              wrote on last edited by
              #7

              You can do one of two things I recon. 1) Store the date of first install in the registry. 2) Store the date of first install in an encrypted file in app directory. In either of the two means above, you check the install date in either the registry or the encrypted file and calculate the days remaining from there. Once it has reached 30 days then you set all controlls on the form to falls or just pop up a messagebox to say that the trail has expired and close the app down once OK has been pressed. If you want the fancy stuff then you may have to spend lots of money to buy an MSI builder or exe builder. I recon the above is much cheaper and should only take a few minutes to code into the app.

              Excellence is doing ordinary things extraordinarily well.

              C 1 Reply Last reply
              0
              • A AspDotNetDev

                Then do what I said here and make the trial based on the total number of hours the application has been open.

                [Forum Guidelines]

                L Offline
                L Offline
                Luc Pattyn
                wrote on last edited by
                #8

                and what is keeping the user from installing the trial app over and over again? :)

                Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


                I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that.


                A 1 Reply Last reply
                0
                • L Luc Pattyn

                  and what is keeping the user from installing the trial app over and over again? :)

                  Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


                  I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that.


                  A Offline
                  A Offline
                  AspDotNetDev
                  wrote on last edited by
                  #9

                  The installation could store the the number of hours open in the registry. The app could check if that exists at install time. If it doesn't, it creates it. If it does, it leaves it as is. When the app is opened, it makes note of the number of ticks that have passed... when it is closed (and perhaps periodically in case the user forces the application close without proper finalization) it will take note of the ticks again, calculate the difference, and add that to the value in the registry. Of course, the user could get around that, but users can get around most anything. That should be sufficiently difficult to prevent most users from toying around with it. Some more ideas to make it more secure:

                  • Do some basic encryption (even with a known/static password) on the value in the registry so the user can't just open regedit and change the value to their liking. Of course, they could remember one of the previously encrypted values, if they thought of that. Or delete the key altogether, but there are ways to detect that too (and ways to get around it, and so on).
                  • Make the EXE modify itself to make note of the value stored in the registry. If it doesn't match the next time the app is run, that means the user did some tampering. This will be sufficiently non-obvious to trip up most users.
                  • Create a hidden folder in one of several predetermined but randomly chosen locations. If that folder exists, it means the app was installed before. This will get in the way of users who like to just delete registry keys and reinstall trial apps.

                  There are various solutions to problems like this, but very simple solutions will trip up the majority of users.

                  [Forum Guidelines]

                  L 1 Reply Last reply
                  0
                  • A AspDotNetDev

                    The installation could store the the number of hours open in the registry. The app could check if that exists at install time. If it doesn't, it creates it. If it does, it leaves it as is. When the app is opened, it makes note of the number of ticks that have passed... when it is closed (and perhaps periodically in case the user forces the application close without proper finalization) it will take note of the ticks again, calculate the difference, and add that to the value in the registry. Of course, the user could get around that, but users can get around most anything. That should be sufficiently difficult to prevent most users from toying around with it. Some more ideas to make it more secure:

                    • Do some basic encryption (even with a known/static password) on the value in the registry so the user can't just open regedit and change the value to their liking. Of course, they could remember one of the previously encrypted values, if they thought of that. Or delete the key altogether, but there are ways to detect that too (and ways to get around it, and so on).
                    • Make the EXE modify itself to make note of the value stored in the registry. If it doesn't match the next time the app is run, that means the user did some tampering. This will be sufficiently non-obvious to trip up most users.
                    • Create a hidden folder in one of several predetermined but randomly chosen locations. If that folder exists, it means the app was installed before. This will get in the way of users who like to just delete registry keys and reinstall trial apps.

                    There are various solutions to problems like this, but very simple solutions will trip up the majority of users.

                    [Forum Guidelines]

                    L Offline
                    L Offline
                    Luc Pattyn
                    wrote on last edited by
                    #10

                    :thumbsup:

                    Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


                    I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that.


                    1 Reply Last reply
                    0
                    • M MumbleB

                      You can do one of two things I recon. 1) Store the date of first install in the registry. 2) Store the date of first install in an encrypted file in app directory. In either of the two means above, you check the install date in either the registry or the encrypted file and calculate the days remaining from there. Once it has reached 30 days then you set all controlls on the form to falls or just pop up a messagebox to say that the trail has expired and close the app down once OK has been pressed. If you want the fancy stuff then you may have to spend lots of money to buy an MSI builder or exe builder. I recon the above is much cheaper and should only take a few minutes to code into the app.

                      Excellence is doing ordinary things extraordinarily well.

                      C Offline
                      C Offline
                      CoderForEver
                      wrote on last edited by
                      #11

                      Hey dude ... u've a nice idea .. but what really my question is ... if the user changed the date ... For e.g .. I installed the app 2 day and today is ..>> 3/5/2010 .. and it is saved in registry ... lets say aftr 15 days ... that is ..>>>3/20/2010 ... if the user changes the time to 3/10/2010 ...It means they faked me 10 days ... and they can do zis forever ... how can i controll this .. thx a lot

                      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