// The following simple example demonstrates how to retreive and store license variables in C-sharp
// The example imports the native Win32 API functions GetEnvironmentVariable and SetEnvironment Variable
staticvoidMain( string[] args)
{
StringBuilder key= newStringBuilder(1000); // reserve 1000 bytes to hold key value
GetEnvironmentVariable("TS_CURRENT_KEY", key);
Console.WriteLine("The current license key is " + key);
Console.WriteLine("Enter a new License Key and press enter:"); stringnew_key=Console.ReadLine(); intresult=SetEnvironmentVariable("TS_CURRENT_KEY", new_key);
if(result==0)
Console.WriteLine("The key you entered was invalid"); else Console.WriteLine("The key you entered has been accepted");
}
}
}
Program output (when packaged using Thinstall and License System 2 enabled)