Your application can store small amounts of data using Thinstall when License System 2 is enabled by using the Environment Variables:
TS_KEYDATA_00 through TS_KEYDATA_99
Typically an application would just open a file or save a registry key with the data it wants to store, however there are disadvantages towards storing data this way:
1. Storing data in file / registry may allow the user to find the data easily using filemon/regmon and delete the data
2. Storing data in file / registry may allow the user to tamper with the contents
3. Storing data in file / registry may allow the user to overwrite data from previous executions or other machines
4. Storing data in file / registry may mean the data is lost when your application is uninstalled & reinstall
5. Storing data in registry may mean the data is not accessable or cannot be updated when the user logs in as a restricted user where registry access is restricted
Thinstall solves all of these problems by storing your data encrypted in multiple locations on the hard drive and system registry. Thinstall also calculates a signature for all stored data so tampering can be detected and prevented.
Typical uses for storing persistant data using Thinstall
1. You can implement custom feature-use counters. i.e. The trial version of your software may only allow the user to use Feature ABC for 10 times.
2. You can store additional user registration information such as Registered User Name and Registered Company Name
3. If your software enables new features by connecting to your website, you store purchased features in these variables once payment has completed.
4. If you want to disable an existing key from working on a user's computer, you can mark one of these variables and check for it each time your program runs.
Example program that uses Thinstall to store persistant data:
// C++ program demonstrate a counter that is incremented each time Thinstall is run
// The counter data is stored on the users computer and associated with the current key (default key if not changed)
// If the user enters a new key, the counter will be set to 0
// If the user later reverts to an older key, the counter will revert to its previous value
#include "stdafx.h"
#include <windows.h>
#include <stdio.h>
int main(int argc, char* argv[])
{
char buf[10];
if (!GetEnvironmentVariable("TS_KEYDATA_01", buf, sizeof(buf))) // get the value of persistant data item 01 for this key
strcpy(buf, "0"); // if not set before, start at 0
int counter=atoi(buf); // convert counter from string to integer
counter++; // increment counter
sprintf(buf, "%d", counter); // convert counter back to string
printf("The counter is now being stored with value = %d\n", counter);
SetEnvironmentVariable("TS_KEYDATA_01", buf); // store the persistant counter for next time program is run
return 0;
}