# Step 1.7: Limiting the free upgrades period

How it works

When VMProtect protects an application it records the date. The licensing system treats this date as a build date of the application. And you can put into a serial number the maximum build date this serial number can work with. Therefore, if you put the current date plus one year to the serial number, it will work with all versions of your programs you will be releasing in a year. A version you release one year and a day after will not work with this serial number, and a user will have a choice: use older version of your program or purchase a new key to work with the latest version of the program for one more year.

Let's try it

Put the line formatted as MaxBuildDate=YYYYMMDD into the ini-file:

    MaxBuildDate=20000101

In the test mode, the licensing system treats today as the build date, so it is important that the date specified in this line already passed. That is, the maximum date is yesterday. Modify the code of the main() function so that it looked like this:

    int main(int argc, char **argv)
    {
            char *serial = "Xserialnumber"; // we set the serial number directly in the code, for simplicity

            int res = VMProtectSetSerialNumber(serial);
            print_state(res);

            if (res)
            {
                    VMProtectSerialNumberData sd = {0};
                    VMProtectGetSerialNumberData(&sd, sizeof(sd));
                    printf("max. build date: y = %d, m = %d, d = %d\n", sd.dtMaxBuild.wYear, sd.dtMaxBuild.bMonth, sd.dtMaxBuild.bDay);
                    printf("please register!\n");
                    return 0;
            }

            printf("I'm registered\n");

            return 0;
    }

Then, upon program run you should see the following:

    state = SERIAL_STATE_FLAG_MAX_BUILD_EXPIRED
    max. build date: y = 2000, m = 1, d = 1
    please register!

By replacing the date in the ini-file to today or tomorrow, we end up with the "working" program:

    state = 0
    I'm registered

Remove the MaxBuildDate=... line from the ini-file so that it would not influence our further steps.

Next step

© 2006-2015 Copyright VMProtect Software