locked
how to set product activation period indipendent of date?? RRS feed

  • Question

  • hi..

    i have developed a software now i want to make a product key that is independent of date.

    how to set counter into the registry so that if user changes the date than also my  counting works fine..

    please help me......

    • Moved by Mike Dos Zhang Tuesday, August 31, 2010 9:00 AM product key topic (From:Visual C# General)
    Friday, August 27, 2010 4:36 AM

All replies

  • hi..

    Hi there !

    i have developed a software now i want to make a product key
    that is independent of date.

    Let's see if I got it right; you want to setup some kind of "time
    bombed"
    license so that your app will only work for a given amount of time and
    will then stop working (or in any case require a renew/license/...)

    If that's what you need, then

    how to set counter into the registry so that if user changes the
    date than also my  counting works fine..

    it sounds like you can't see the forest since there are all those
    trees :) - seriously, you're taking the wrong approach, don't
    use date/time, use an interval, let me make an example

    I won't go over encryption or obfuscation here, nor over all
    the related issues, but what follow should give you a starting
    point; let's say you store the following somewhere (say into
    the registry)

    InstallDate DWORD - date/time of installation of your application

    LastStart DWORD - date/time of the last startup of the application

    ElapsedTime DWORD - counter; total runtime in minutes for your
    application (i.e. the time elapsed from the start to the exit will be
    summed up here)

    SaltedHash STRING - a "salted" MD5 hash of the above values

    Now let's say you want your app to run for 30 days, that is for a
    max of 43200 minutes

    Upon setup you set the InstallDate to current datetime, the LastStart
    to (say) 1-1-1980, the ElapsedTime to 0 and calculate and store the
    salted hash for those values (and recalculates/stores the hash)

    Upon first startup, your app stores the startup datetime in "LastStart"
    then, at regular intervals (and upon shutdown) it increases the elapsed
    time counter and stores the total number of minutes it has been running
    into ElapsedTime (and, again, recalculates/stores the hash)

    After the ElapsedTime goes over 43200 (minutes) that is, 30 days,
    your app will then stop working

    Also, in case the clock is set back, you may check the "LastStart" and
    if
    the current datetime falls "before" the "LastStart" or the "InstallDate"
    you
    may refuse starting ... or you may just keep increasing the total usage
    time for your app in "ElapsedTime" and use it as your trigger

    The "SaltedHash" entry will protect such entries so that if they'll be
    manually edited the hash won't match and your app may then refuse
    to start or take whatever action you want

    Wednesday, September 1, 2010 2:53 PM