Using the LDK when the Target Machine Has Internet Access (Online Mode)
- Build a new project that utilizes the LDK module to acquire the license key.
You can use the LDK module in any project. But, we recommend building a separate project so that it will be easier to isolate the licensing from your normal application operation.
- Add the AccuLicClient.dll to your project references. AccuLicClient.dll is available in the following folders:
- $INSTALLDIR\Licensing\Deployment\x64
- $INSTALLDIR\Licensing\Deployment\x86
- You'll need to register AccuLicClient.dll on the target machine during runtime, for example, as part of your installation or licensing process.
- In your code, run the following to COM-register AccuLicClient.dll on the target machine:
32-bit |
Copy Code |
%SYSTEMROOT%\System32\regsvr32.exe AccuLicClient.DLL |
64-bit |
Copy Code |
%SYSTEMROOT%\syswow64\regsvr32.exe AccuLicClient.DLL |
- Add the license configuration file (and the access key file, if you’re assigning access keys) that you downloaded in step 1: Generate a License Configuration File.
- When using the LDK module, these are the main steps to be done in your code (see the code example below for details):
- Set the path to the license configuration file using the ConfigPath property.
- Call the LicKey property to see if a license is already on the target machine (to avoid unnecessary consumption of runtime licenses).
- If the machine is not already licensed, download a license using the GetLicKeyAuto method.
- Here, you can provide an access key. You must provide an access key if you are using Annual/time-based Licenses; if you’re not using Annual Licenses, access keys are optional so that you can track which machines are assigned licenses. Otherwise, the licensing component will assign an access key for you.
- Execute your project on the target machine.
On successfully executing your code, a license is downloaded from the Accusoft server and placed into the registry.
- The LDK will return a Result code indicating the license status.
The code example below demonstrates how you can use the LDK module. |
Copy Code |
// Instantiate the LDK ActiveX component
IDeploymentComponent ldk = new DeploymentComponent();
// Set the path to the configuration file provided
// when the runtime licenses were purchased.
ldk.ConfigPath = @"C:\config.txt";
//Check to see if a license is currently on the machine
//If so, then there’s no need to proceed
If (ldk.LicKey != "")
{
MessageBox.Show("A license already exists on this machine.");
return;
}
// Attempt to get the next available license.
// Pass an Access Key as a parameter if you are using annual licensing or have opted to use Access Keys
ldk.GetLicKeyAuto("");
if (ldk.ResultCode != enumLdkErrorCodes.LDK_SUCCESS)
{
// Automatic Registration Failed - A temporary license
// has been installed but will expire in 14 days.
// You will need to add code to notify your user of this issue and the 14 day
// expiration.
if (ldk.ResultCode == enumLdkErrorCodes.LDK_ERR_INET_CONN_BROKEN)
{
// You will need to handle what happens when your user does not have an internet connection on the target machine.
// See the next section for information on manual (offline) registration
}
}
else
{
// The license has been registered and installed.
} |
Licensing Development Kit Interface
The interface to the LDK is shown below:
|
Copy Code |
interface IDeploymentComponent : IDispatch
{
[propget, id(1)] HRESULT LicKey ( [out, retval] BSTR* pVal );
[propput, id(1)] HRESULT LicKey ( [in] BSTR newVal );
[propget, id(2)] HRESULT srvURL ( [out, retval] BSTR* pVal );
[propput, id(2)] HRESULT srvURL ( [in] BSTR newVal );
[propget, id(3)] HRESULT ConfigPath ( [out, retval] BSTR* pVal );
[propput, id(3)] HRESULT ConfigPath ( [in] BSTR newVal );
[propget, id(4)] HRESULT ResultString ( [out, retval] BSTR* pVal );
[propget, id(5)] HRESULT ResultCode ( [out, retval] enumLdkErrorCodes* pVal );
[id(6)] HRESULT GetLicKeyAuto ( [in] BSTR accKey );
[id(7)] HRESULT GetHdwKey ( [in] BSTR accKey
, [out,retval] BSTR* hdwKey );
[id(8)] HRESULT StartEvalPeriod ( void );
[id(10)] HRESULT GetEvalPeriod ( [out, retval] long* pVal );
}; |
LDK Properties
- LicKey - Stores the License Key to the registry when it is set, and reads it from the registry during the get operation.
- srvURL - Gets and sets the URL path to the licensing web service. The default is the URL path to Accusoft's Deployment Licensing Service.
- ConfigPath - Gets and sets a path to the deployment configuration file. Multiple products can be registered at one time by setting the filenames as a semicolon-delimited list: e.g., "c:\config.txt;c:\config2.txt".
- ResultString - Contains the string descriptions of any error that may have occurred during the last operation.
- ResultCode - Can be used to contain any of the error codes described in Licensing Component Error Codes and Messages.
LDK Methods
- GetLicKeyAuto: Obtains a License Key for the end user's system using the automatic (or connected) scenario. It takes an Access Key as its input parameter, and stores the obtained license key in the registry. If you choose not to distribute individual Access Keys, the accKey argument should be an empty string.
- GetHdwKey: Obtains a hardware key from the current machine and returns it (as hdwKey). If you choose not to distribute individual access keys, the accKey argument should be an empty string.
- StartEvalPeriod: Sets an evaluation licensing mode for the product and starts an evaluation period. This method is provided so you can distribute an evaluation version of your application, without having to distribute Access Keys to people who would like to evaluate your software. Using this method you can license Accusoft components on the end user's system for a limited time - the default is 30 days, but it can be customized per request to Accusoft. If the evaluators purchase your software, you can then issue them an access key using either the automatic or manual scenarios to obtain permanent component licenses, just as Accusoft does for its evaluators.
- GetEvalPeriod: Obtains the remaining time on an evaluation (in days). It returns EvalPeriod < 0 if the evaluation period is expired.