Você está na página 1de 18

License Manager API

User's guide

Copyright 2008-2011 Neurotechnology. All rights reserved

License Manager API

Table of Contents
1 Preface

2 NLicManGenerateLicense@NChar *@NInt *@NUInt


*@NChar *@NSizeType

3 NLicManGenerateSerial@NUInt@NInt@NInt *@NChar
*@NSizeType

4
4
NLicManGetLongProductNameEx@NUInt@NLicenseType@N
Char
*@NSizeType
5
5
NLicManGetShortProductNameEx@NUInt@NLicenseType@N
Char
*@NSizeType
6 Introduction

7 API Reference

7.1 C/C++ Reference

7.1.1 Functions

7.1.1.1 NLicManDongleGetDistributorId Function

7.1.1.2 NLicManDongleGetLicenseCountEx Function

7.1.1.3 NLicManFindFirstDongle Function

7.1.1.4 NLicManFindNextDongle Function

7.1.1.5 NLicManGetLicenseCountEx Function

7.1.1.6 NLicManGetLicenseData Function

7.1.1.7 NLicManGetProductIds Function


7.1.2 Macros

10
10

7.1.2.1 N_LIC_MAN_MAX_LICENSE_LENGTH Macro

10

7.1.2.2 N_LIC_MAN_MAX_SERIAL_LENGTH Macro

11

7.2 .NET Reference


7.2.1 Neurotec.Licensing Namespace

11
11
ii

License Manager API


7.2.1.1 Classes
7.2.1.1.1 NLicenseManager Class

11
11

7.2.1.1.1.1 NLicenseManager Fields

12

NLicenseManager.DllName Field

12

7.2.1.1.1.2 NLicenseManager Methods

12

NLicenseManager.FindFirstDongle Method

12

NLicenseManager.FindNextDongle Method

12

NLicenseManager.GenerateLicense Method

12

NLicenseManager.GenerateSerial Method

13

NLicenseManager.GetInfo Method

13

NLicenseManager.GetLicenseCount Method

13

NLicenseManager.GetLicenseData Method

14

NLicenseManager.GetLongProductName Method

14

NLicenseManager.GetProductIds Method

14

NLicenseManager.GetShortProductName Method

14

iii

License Manager API

1 Preface

Brief information about this user's guide:


Release date: 4/11/2011
Version: 1.6.0.1

License Manager API

2 NLicManGenerateLicense@NChar
*@NInt *@NUInt *@NChar *@NSizeType
Generates product license to specified memory buffer.
Parameters
Parameters

Description

pId

[in] A string that contains computer Id data from computer Id


file. Computer Id file should be scanned before passing it to
function. Char buffer passed to function should contain null
terminating character.

pSequenceNumber

[out] Sequence number used for licenses accounting.

pProductId

[in] Id of a product for which license was generated. Used for


licenses accounting.

pLicBuf

[out] Memory buffer that contains generated license data.

licBufSize

[in] Size of pLicBuf.

Returns
If the function succeeds the return value is N_OK.
If pId , pLicBuf, pSerialNumber or pProductId is NULL an error code is returned.
Remarks
When generating licenses these constraints should be considered:
1. Only one instance of license generating process should be present.
2. pg.exe can not be started.

License Manager API

3
NLicManGenerateSerial@NUInt@NInt@N
Int
*@NChar *@NSizeType
Generates serial number for specified product.
Parameters
Parameters

Description

productId

[in] Id of a product to generate serial number.

pSequenceNumber

[in] Sequence number used for licenses accounting. User


must store this number in own database.

pDistributorId

[in] Id of a distributor who generated serial number.

pSnBuf

[out] Memory buffer that contains generated serial number.

snBufLength

[in] Size of memory buffer pSnBuf.

Returns
If the function succeeds the return value is N_OK.
If pSnBuf , pSerialNumber or pDistributorId is NULL or snBufLength is less than (N_LIC_MAN_MAX_SERIAL_LENGTH (
page 11) + 1) an error code is returned.

License Manager API

4
NLicManGetLongProductNameEx@NUIn
t@NLicenseType@NChar
*@NSizeType
Retrieves full name of a product specified by product Id.
Parameters
Parameters

Description

productId

[in] Id of a product to retrieve full name.

type

[in] License type.

szValue

[out] Full product name.

valueSize

[in] Size of memory buffer containing string.

Returns
If the function succeeds the return value is N_OK.
Otherwise an error code is returned.

License Manager API

5
NLicManGetShortProductNameEx@NUIn
t@NLicenseType@NChar
*@NSizeType
Retrieves short name of a product specified by product Id.
Parameters
Parameters

Description

productId

[in] Id of a product to retrieve short name.

type

[in] License type.

szValue

[out] Full product name.

pValue

[in] Size of memory buffer containing string.

Returns
If the function succeeds the return value is N_OK.
Otherwise an error code is returned.

License Manager API

6 Introduction
License Manager API is useful to develop your own license managing software. Neurotechnology can provide USB dongles
that contains amount of licenses of specified products. Dongle can be used to generate single computer licenses
independent from Neurotechnology.

7.1 C/C++ Reference

License Manager API

Functions

7 API Reference
This chapter contains API reference which helps to develop licenses managing software.

7.1 C/C++ Reference


These libraries are required for License Manager:
NLicenseManager.dll
NCore.dll
Functions
Name

Description

NLicManDongleGetDistributorId (
page 8)

Retrieves from dongle distributor Id.

NLicManDongleGetLicenseCountEx Retrieves number of licenses in a specified dongle.


( page 8)
NLicManFindFirstDongle (

page 8) Used to get handle to the first attached dongle.

NLicManFindNextDongle (

page 9) Finds next attached dongle. This function is used together with
NLicManFindFirstDongle ( page 8) function.

NLicManGetLicenseCountEx (
page 9)
NLicManGetLicenseData (
NLicManGetProductIds (

Retrieves licenses count for a product specified by Id.

page 9) Retrieves license data for a specified product license.


page 10) Retrieves a list of all Neurotechnology products Ids.

Macros
Name

Description

N_LIC_MAN_MAX_LICENSE_LENGTH (
page 10)

Maximum length of product license.

N_LIC_MAN_MAX_SERIAL_LENGTH (
11)

page

Maximum length of product's serial number.

7.1.1 Functions
The following table lists functions in this documentation.
Functions
Name

Description

NLicManDongleGetDistributorId (
page 8)

Retrieves from dongle distributor Id.

NLicManDongleGetLicenseCountEx Retrieves number of licenses in a specified dongle.


( page 8)
NLicManFindFirstDongle (

page 8) Used to get handle to the first attached dongle.

NLicManFindNextDongle (

page 9) Finds next attached dongle. This function is used together with
NLicManFindFirstDongle ( page 8) function.

NLicManGetLicenseCountEx (
page 9)

Retrieves licenses count for a product specified by Id.

7.1 C/C++ Reference


NLicManGetLicenseData (
NLicManGetProductIds (

License Manager API

Functions

page 9) Retrieves license data for a specified product license.


page 10) Retrieves a list of all Neurotechnology products Ids.

7.1.1.1 NLicManDongleGetDistributorId Function


Retrieves from dongle distributor Id.
C++
NResult N_API NLicManDongleGetDistributorId(HNLicManDongle hDongle, NInt * pDistributorId);
Parameters
Parameters

Description

HNLicManDongle hDongle

[in] Handle to dongle.

NInt * pDistributorId

[out] Retrieved distributor Id value.

Returns
If the function succeeds the return value is N_OK.
If hDongle or pDistributorId is NULL an error code is returned.
If hDongle or pCount is NULL an error code is returned.
Remarks
To get Ids of all products use NLicManGetProductIDs function. Using functions NLicManGetLongProductName and
NLicManGetShortProductName you can get the name of product specified by Id.

7.1.1.2 NLicManDongleGetLicenseCountEx Function


Retrieves number of licenses in a specified dongle.
C++
NResult N_API NLicManDongleGetLicenseCountEx(HNLicManDongle hDongle, NUInt productId,
NLicenseType type, NInt * pCount);
Parameters
Parameters

Description

HNLicManDongle hDongle

[in] Handle to dongle.

NUInt productId

[in] License count is returned for specified by productId.

NLicenseType type

[in] License type.

NInt * pCount

[out] Available licenses for specified product Id.

Returns
If the function succeeds the return value is N_OK.
If hDongle or pCount is NULL an error code is returned.
Remarks
To get Ids of all products use NLicManGetProductIDs function. Using functions NLicManGetLongProductName and
NLicManGetShortProductName you can get the name of product specified by Id.

7.1.1.3 NLicManFindFirstDongle Function

Used to get handle to the first attached dongle.

7.1 C/C++ Reference

License Manager API

Functions

C++
NResult N_API NLicManFindFirstDongle(HNLicManDongle * pHDongle);
Parameters
Parameters

Description

HNLicManDongle * pHDongle

[out] Handle to the first dongle.

Returns
If the function succeeds the return value is N_OK.
Remarks
NlmDongleFindNext and NLicManFindFirstDongle functions can be used to iterate through all attached dongles.
NlmDongleFindNext is used to get handles of all the subsequent dongles attached.
When dongle handle is no longer needed, it must be freed using NlmDongleFree.

7.1.1.4 NLicManFindNextDongle Function


Finds next attached dongle. This function is used together with NLicManFindFirstDongle (

page 8) function.

C++
NResult N_API NLicManFindNextDongle(HNLicManDongle * pHDongle);
Parameters
Parameters

Description

HNLicManDongle * pHDongle

[out] Handle to next dongle.

Returns
If the function succeeds the return value is N_OK.

7.1.1.5 NLicManGetLicenseCountEx Function


Retrieves licenses count for a product specified by Id.
C++
NResult N_API NLicManGetLicenseCountEx(NUInt productId, NLicenseType type, NInt * pCount);
Parameters
Parameters

Description

NUInt productId

[in] License count is returned for product by specified Id.

NLicenseType type

[in] License type.

NInt * pCount

[out] Number of licenses for specified product.

Returns
If the function succeeds the return value is N_OK.
If pCount is NULL an error code is returned.
See Also
NLicManGetProductIDs

7.1.1.6 NLicManGetLicenseData Function


Retrieves license data for a specified product license.
9

7.1 C/C++ Reference

License Manager API

Macros

C++
NResult N_API NLicManGetLicenseData(NChar * szId, NInt * pSequenceNumber, NUInt *
pProductId, NInt * pDistributorId);
Parameters
Parameters

Description

NInt * pSequenceNumber

[out] Sequence number used for licenses accounting.

NUInt * pProductId

[out] Id of a product to retrieve license data.

NInt * pDistributorId

[out] Id of a distributor who generated license.

pId

[in] A string that contains computer Id file data. Computer Id


file should be scanned before passing it to function. Char
buffer passed to function should contain null terminating
character.

Returns
If the function succeeds the return value is N_OK.

7.1.1.7 NLicManGetProductIds Function


Retrieves a list of all Neurotechnology products Ids.
C++
NResult N_API NLicManGetProductIds(NUInt * arProductsIds);
Parameters
Parameters

Description

NUInt * arProductsIds

[out] Memory buffer that contains Ids of all Neurotechnology


products.

Returns
If the function succeeds the return value is N_OK.
Otherwise an error code is returned.

7.1.2 Macros
The following table lists macros in this documentation.
Macros
Name

Description

N_LIC_MAN_MAX_LICENSE_LENGTH (
page 10)

Maximum length of product license.

N_LIC_MAN_MAX_SERIAL_LENGTH (
11)

page

Maximum length of product's serial number.

7.1.2.1 N_LIC_MAN_MAX_LICENSE_LENGTH Macro


Maximum length of product license.

C++
#define N_LIC_MAN_MAX_LICENSE_LENGTH 6400

10

7.2 .NET Reference

License Manager API

Neurotec.Licensing Namespace

7.1.2.2 N_LIC_MAN_MAX_SERIAL_LENGTH Macro


Maximum length of product's serial number.
C++
#define N_LIC_MAN_MAX_SERIAL_LENGTH 39

7.2 .NET Reference


These libraries are required for License Manager:
Neurotec.LicenseManager.dll
Neurotec.dll

Namespaces
Name

Description

Neurotec.Licensing (

page 11)

Provides functionality for Neurotecnology products licensing.

7.2.1 Neurotec.Licensing Namespace


Provides functionality for Neurotecnology products licensing.
Classes
Name

Description

NLicenseManager (

page 11)

Provides functionality for licenses management.

7.2.1.1 Classes
The following table lists classes in this documentation.
Classes
Name

Description

NLicenseManager (

page 11)

Provides functionality for licenses management.

7.2.1.1.1 NLicenseManager Class


Provides functionality for licenses management.
C#
public static class NLicenseManager;
NLicenseManager Fields
Name
DllName (

Description
page 12)

Name of dynamically linked library that contains unmanaged part of


LicenseManager functionality.

11

7.2 .NET Reference

License Manager API

Neurotec.Licensing Namespace

NLicenseManager Methods
Name

Description

FindFirstDongle (

page 12)

Retrieves handle to the first attached dongle.

FindNextDongle (

page 12)

Finds next attached dongle. This method is used together with


FindNextDongle method.

GenerateLicense (
GenerateSerial (
GetInfo (

page 12)
page 13)

page 13)

GetLicenseCount (
GetLicenseData (

Generates serial number for a specified product.


Retrieves information about the License Manager library.

page 13)
page 14)

GetLongProductName (
GetProductIds (

Generates product license from computer Id.

page 14)

page 14)

GetShortProductName (

Retrieves licenses count for a product specified by Id.


Retrieves license data for a specified product license.
Retrieves full name of a product specified by product Id.
Retrieves a list of all Neurotechnology products Ids.

page 14) Retrieves short name of a product specified by product Id.

7.2.1.1.1.1 NLicenseManager Fields


7.2.1.1.1.1.1 NLicenseManager.DllName Field
Name of dynamically linked library that contains unmanaged part of LicenseManager functionality.
C#
public const string DllName = "NLicenseManager";
Remarks
Neurotec.LicenseManager.dll is a wrapper of the NLicenseManager.dll.

7.2.1.1.1.2 NLicenseManager Methods


7.2.1.1.1.2.1 NLicenseManager.FindFirstDongle Method
Retrieves handle to the first attached dongle.
C#
public static NLicManDongle FindFirstDongle();
Returns
If the method succeeds the return value is handle to attached dongle. Otherwise, the return value is null.
Remarks
FindNextDongle ( page 12) and FindFirstDongle methods can be used to iterate through all attached dongles.
FindNextDongle ( page 12) is used to get handles of all the subsequent dongles attached.

7.2.1.1.1.2.2 NLicenseManager.FindNextDongle Method


Finds next attached dongle. This method is used together with FindNextDongle method.
C#
public static NLicManDongle FindNextDongle();
Returns
If the function succeeds the return value is a handle to found dongle. Otherwise, the return value is null.

7.2.1.1.1.2.3 NLicenseManager.GenerateLicense Method


Generates product license from computer Id.

12

7.2 .NET Reference

License Manager API

Neurotec.Licensing Namespace

C#
public static string GenerateLicense(string id, out int sequenceNumber, out uint productId);
Parameters
Parameters

Description

string id

String that contains computer Id file data. You should read


computer ID file to this string.

out int sequenceNumber

Sequence number used for licenses accounting.

out uint productId

ID of a product for which license was generated.

Returns
If the method succeeds the return value is a string that contains generated license data.
Remarks
For every generated license count of licenses in a dongle will be decreased by 1.
When generating licenses these constraints should be considered:
1. Only one instance of license generating process should be present.
2. pg.exe can not be started.

7.2.1.1.1.2.4 NLicenseManager.GenerateSerial Method


Generates serial number for a specified product.
C#
public static string GenerateSerial(uint productId, int sequenceNumber, out int
distributorId);
Parameters
Parameters

Description

uint productId

Id of a product to generate serial number.

int sequenceNumber

Sequence number used for licenses accounting. User must


store sequence number in own database.

out int distributorId

ID of a product for which serial number should be generated.

Returns
If the method succeeds a string which contains generated serial numer is returned.

7.2.1.1.1.2.5 NLicenseManager.GetInfo Method


Retrieves information about the License Manager library.
C#
public static NLibraryInfo GetInfo();
Returns
NLibraryInfo structure that contains information about the library.

7.2.1.1.1.2.6 NLicenseManager.GetLicenseCount Method


Retrieves licenses count for a product specified by Id.
C#
[Obsolete("Use GetLicenseCount(uint, NLicenseType) instead.")]
public static int GetLicenseCount(uint productId);

13

7.2 .NET Reference

License Manager API

Neurotec.Licensing Namespace

Parameters
Parameters

Description

uint productId

ID of product to retrieve licenses.

Returns
Returns license count left to generate for specified product (for non concurrent licenses only) and license count available.
Exceptions
Exceptions

Description

Exception

Is thrown when when dongle not connected or other error


occurred.

7.2.1.1.1.2.7 NLicenseManager.GetLicenseData Method


Retrieves license data for a specified product license.
C#
public static void GetLicenseData(string id, out int sequenceNumber, out uint productId,
out int distributorId);
Parameters
Parameters

Description

string id

A string that contains computer Id file data. Computer Id file


should be scanned before passing it to method. String
passed to method should contain null terminating character.

out int sequenceNumber

Sequence number used for licenses accounting.

out uint productId

Product Id.

out int distributorId

Distributor Id.

7.2.1.1.1.2.8 NLicenseManager.GetLongProductName Method


Retrieves full name of a product specified by product Id.
C#
[Obsolete("Use GetLongProductName(uint, NLicenseType) instead.")]
public static string GetLongProductName(uint productId);
Parameters
Parameters

Description

uint productId

Id of a product to retrieve full name.

Returns
A string that contains full product name specified by productID.

7.2.1.1.1.2.9 NLicenseManager.GetProductIds Method


Retrieves a list of all Neurotechnology products Ids.
C#
public static uint[] GetProductIds();
Returns
An UInt array that contains all products Ids.

7.2.1.1.1.2.10 NLicenseManager.GetShortProductName Method


Retrieves short name of a product specified by product Id.

14

7.2 .NET Reference

License Manager API

Neurotec.Licensing Namespace

C#
[Obsolete("Use GetShortProductName(uint, NLicenseType) instead.")]
public static string GetShortProductName(uint productId);
Parameters
Parameters

Description

uint productId

Id of a product to retrieve short name.

Returns
A string that contains short product name.

15

Você também pode gostar