License Environment Variables
Previous Top Next


Special notes:
· Visual Basic users must use SetEnvironmentVariable and GetEnvironmentVariable not GetEnv/SetEnv
· Most keys are read only, if you change the environment variable value it will have no effect. The exceptions are TS_CURRENT_KEY and TS_KEYDATA_00 through TS_KEYDATA_99



Environment variables accessable to your program:

TS_CURRENT_KEY (read/write) - This value contains the current key in use, if no key has been supplied by the user this will be the default key.
Unlike all other Environment variables, this variable is Read/Write.
Calling SetEnvironmentVariable("TS_CURRENT_KEY", "new_key_value") has a special function when running under
Thinstall with License System 2 enabled.

SetEnvironmentVariable has a return code of 1 if the key was successfully decoded and set as the new current key.
When the key decodes successfully, all other environment variables listed on this page are modified to reflect the new key

SetEnvironmentVariable has a return code of 0 if the key does not decode to a valid key using your password
If the key does not decode successfully, the value of TS_CURRENT_KEY does not change nor do any other environment variables.

TS_MAXDAYS (read only) -The maximum number of days the key can be used for.
Format is interger >= 0
If current license key has no maximum day usage limit this environment variable is set to NULL (no value)

TS_DAYSUSED (read only) - Number of days since the current license key was first used
Format is interger >= 0
This value is always set, even if the current key has no restrictions on the maximum number of days
If you wish to display your own license dialog, you should check to make sure this value is <=TS_MAXDAYS

TS_DAYSLEFT (read only)
Format is interger >= 0
This value is set only if TS_MAXDAYS or TS_EXPDATE are set, if the current key has no relative or absolute time limit this value is NULL (no value)
Because you can set absolute and relative time limits in the same license key, this value will be set to the maximum number of days before the current key expires.
For example if has 5 days remaining for 30-day trial, and you have also placed an abolsute date limit of 2004-01-01 where today (2003-12-31), the value of TS_DAYSLEFT
will be 1 because only one day remains in the second limitation. The number of days left will also include time-additions from previous keys. See (When Thinstall adds
key times).


TS_RUNON (read only) - Current number of times program has been run
Format is interger >= 1
This value is always set, even if the current key has no restrictions on the maximum number of runs.
If you wish to display your own license dialog, you should check to make sure this value is <=TS_MAXRUNS

TS_LICINFO (read only) - License information embedded in the current license key
This variable is useful for passing additional information to your program from the key generator. For example:
· Can be used to enable or disable specific features inside your program. Your program can check for specific strings in the TS_LICINFO variable before allowing the user to preform various options.
· Can be used to embed the name of the License owner. Your program can display the name of the License Owner inside the program. This helps to discourage users from improperly sharing their license code.
If current license key has no embedded license information, this environment variable is set to NULL (no value)

TS_MAXRUNS (read only) - Maximum number of runs allowed by the current license key
Format is interger >= 0
If current license key has no Maximum runs limit this environment variable is set to NULL (no value)

TS_MACID_REQ (read only) - Machine ID required by the current license key
Format is a 16 character string
If current license key has no required machine ID this environment variable is set to NULL (no value)

TS_MACID (read only) - The current Machine ID of the local system
Format is a 16 character string
This value is always set.
If you wish to display your own license dialog, you should check to make sure this value matches TS_MACID_REQ

TS_EXPDATE (read only) - Absolute Expiration date of current license key
Format is YYYY-MM-DD (MM and DD are always 2 digits)
If current license has no Absolute Expiration date, this environment variable is set to NULL (no value)

TS_FIRSTRUN (read only) - Date this license key was first used
Format is YYYY-MM-DD (MM and DD are always 2 digits)
This value will always be set.
This value only changes if a new license key is entered.
If a license key is entered which was previously used, the old TS_FIRSTRUN date is used for that key.

TS_EXPIRED (read only) - Determines if the current license has expired
This value is set to "1" if the current license has expired for any reason (time restriction, machine ID doesn't match, forced expiration, etc)
If the current license key has not expired this environment variable is set to NULL (no value)
Note: this value will never be set if Thinstall's GUI is used to display the license dialogs because the user will never run your program unlicensed.

TS_CURRENT_VER (read only) - Contains the current version of the running application
Format is X.X.X.X where X is a 16-bit number (0-65536)

For easier parsing, each number is always 0 padded to the left to form 6 digits. For example 1.2.3.5 becomes:
000001.000002.000003.000005

TS_MIN_VER (read only) - Contains the minimum software version this key can be used for
Format is X.X.X.X where X is a 16-bit number (0-65536)
The order of importance is left to right. So 1.0.0.0 is greater than 0.2.0.0 and 0.0.0.10
Keys that contain a simple version numbers will generate smaller keys. For example 1.0.0.0 will generate a
smaller key than 29432.2882.12992.2002

For easier parsing, each number is always 0 padded to the left to form 6 digits. For example 1.2.3.5 becomes:
000001.000002.000003.000005


TS_MAX_VER (read only) - Contains the maximum software version this key can be used for
Format is X.X.X.X where X is a 16-bit number (0-65536)
The order of importance is left to right. So 1.0.0.0 is greater than 0.2.0.0 and 0.0.0.10
Keys that contain a simple version numbers will generate smaller keys. For example 1.0.0.0 will generate a
smaller key than 29432.2882.12992.2002

For easier parsing, each number is always 0 padded to the left to form 6 digits. For example 1.2.3.5 becomes:
000001.000002.000003.000005


TS_KEYDATA_00 through TS_KEYDATA_99 (read / write) - Allows you to store application-specific persistent data that will be available the next time your program runs.
Format is any valid string. Strings must be less than 30,000 characters long
You can store any data you want into these variables. Stored data is visible to your program the next time it runs by accessing the same environment variable.
If a variable has not been initialized, GetEnvironmentVariable will return 0 as if the environment variable did not exist.
Data stored in these variables is specific to the current key in use. If the key is changed, the values will reflect the new key.
To store global data (for all keys), you should use TS_CURRENT_KEY to change to the default key, set the value desired, and then use
TS_CURRENT_KEY again to change back to the original key.
See the following sample program for how to use this to implement a program run counter.

Environment variables that are always set when License System 2 is enabled

TS_CURRENT_KEY
TS_DAYSUSED
TS_RUNON
TS_MACID
TS_FIRSTRUN
TS_CURRENT_VER
TS_KEYDATA_00 through TS_KEYDATA_99

Environment variables that are optionally set when License System 2 is enabled

TS_MAXDAYS - set when current license key contains a maximum number of days, otherwise NULL
TS_LICINFO - set when current license key contains additional License Information, otherwise NULL
TS_MACID_REQ - set when current license key contains a "Required Machine ID", otherwise NULL
TS_EXPDATE - set when current license key contains an Absolute Expiration Date, otherwise NULL
TS_EXPIRED - set when the current license key has expired for any reason, otherwise NULL
TS_MIN_RELDATE - set when the current license key has a minimum software release date, otherwise NULL
TS_MAX_RELDATE - set when the current license key has a maximum software release date, otherwise NULL