My company will be providing our users with a license key that the user will need in order to access our plug-in’s functionality.
The functionality I have now is that a modal pops up when the command starts asking for a license. Then, it verifies the license, and the user can continue to use the plugin.
However, as of now the user has to input that license every time they start the command, and I’m looking for a way to save that license key somewhere, so the user does not have to input it every time they start the command
You can save the license key in a specific file or in Windows Registry (or Mac equivalent).
For each command you can call a function that check if the license exists before running the actual command code. If the file does not exist or the license key is not valid, it prompt the user to enter it.
Something like this:
string licenseFileName = "C:/Users/username/example.lic";
string key = System.IO.File.ReadAllText(licenseFileName);
// Do your key checking here
Moved to Developer category
This is definitely the kind of functionality I’m looking for, but now my question would be if there’s a way to save/access that license file without a full filepath. For example, the “/username” is going to be different for each user, and that would cause a problem, right?
Rhino plug-ins are capable of storing per-user, persistent settings to a settings (xml) file.
If you want to know the location of where Rhino will create, read, and write this settings file, then just get the SettingsDirectory property on your plug-in.
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
This directory seems like a reasonable place to store a per-user license file.
This is working while Rhino is running. If I enter the license key it is saved, and the next time I run the plugin it can find the saved license key. However, after closing Rhino and re-opening it can no longer find that key. Does persistent settings not save data that can last for a time when Rhino is closed?
Since you have not provided any code that demonstrates how you are setting persistent settings, I can’t really help.
Have a look at the following sample and see if it gives you any ideas.
TestLicenseKeyPlugIn.zip (27.5 KB)