Using the LDK when the Target Machine Does Not Have Internet Access (Offline Mode)
If you are using the LDK and anticipate that there will be target machines that do not have internet access for security or other reasons, you will need to account for some additional interaction points, some of them manual. The instructions here delineate the general process and indicate where you will need to write some additional code to account for these interaction points.
- 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 apart 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 on a target machine that does not have internet access, these are the main steps to be done in your code:
- Obtain the hardware key from the target machine (via GetHdwKey())
The following code example extends the example provided in the Using the LDK when the Target Machine Has Internet Access (Online Mode) to demonstrate how to handle the offline scenario (i.e., when the target machine does not have an internet connection).
Example |
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.
// Get the hardware key for the target system. Note
// that you may optionally pass an Access Key
string hardwareKey = ldk.GetHdwKey("");
// Write the hardware key to some type of removable media.
// Uncomment the next line and use your custom method ...
// ApplicationSpecificMethodToWriteHardwareKey(hardwareKey);
}
}
else
{
// The license has been registered and installed.
}
|
- You will need to handle how you will get the hardware key to a system with internet access so that your user can receive the returned license key. For example, they could copy it into a text file and send it to you so that you could obtain a license on a system that has internet access (e.g., copy to a portable storage device, network drive, or via email).
- On a machine with internet access:
- Open a browser and go to the Accusoft Licensing Center page.
- Paste the hardware key.
- Click Download License to download a text file with the generated license key.
- You can download your access key listing from your license pool in the customer portal. You must provide an access key if you are using Annual Licenses; if you’re not using Annual Licenses, then access keys are optional. Access keys allow you to track which machines are assigned licenses. In cases where you don't supply an access key, the licensing component will assign an access key for you.
- Copy the file with the license key (and access key, if using) into a text file that you can transfer back to the offline target machine.
- Copy and paste the license key back onto the machine to be licensed. Set the LicKey property in the LDK module with its value to have it placed onto the system.
Example |
Copy Code |
// After taking the hardware key to a system with an Internet
// connection and acquiring the license key string from the
// manual registration website, read the key into your
// application.
// Uncomment the next line and use your custom method …
// string manuallyAcquiredLicenseKey = ApplicationSpecificMethodToReadLicenseKey();
// Install the license key
ldk.LicKey = manuallyAcquiredLicenseKey; |
- Execute your built application on the target machine.
On successfully executing your code, the license provided in the LicKey property is then placed into the registry.
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.