Methods

Top  Previous  Next

 

METHODS

 

Items covered in this topic

 

General Methods

Methods to Access the OLM

New Functions to Start the Trial Period

Utilitarian Methods and Functions

 

 

GENERAL METHODS

 

CalcUserId()

function CalcUserID(Uname:string):word;

This method takes a string parameter that may be the user name and return a number based in this parameter. Is used into the GetIcode() method to calculate the part of the InstallCode corresponding to the Use_Name source when this source is active into the InstallCodeSources property.

 

CheckKey()

function checkkey(i,v,a:word;ic,RKey:string):boolean;

This method does a verification of the key "RKey" passed as parameter. Call internally to the DecodeRegKey() method, then if the error code returned is zero (no error) return true else return false.

 

DecodeRegKey()

function DecodeRegKey(i, v, a: word; ic, RKey, enckey: string;

 var app_id, icod_ver, begindate, Days: word;

 var idx, Users, Instances, KeyType: byte; var Values: string): Integer;

 

This method takes the following input parameters. The first ones (i,v,a,ic) with the purpose of verify the registration key comparing these values with the existing into the key.

 

i     : (word) key index. (if 9999 this value will be not verified)

v     : (word) version, valid for generic keys. (if 0 this value will be not verified)

a     : (word) AppID. (if 0 this value will be not verified)

ic    : (string) InstallCode. (if '' this value will be not verified)

RKey  : (string) Registration Key.

 

The "RKey" Registration Key is decrypted and decoded into its component fields  and returned into the following output parameters:

 

app_id     : (word) AppID property

icod_ver   : (word) ICode property. Version if the key is generic.

begindate  : (word) StartDate. where start the authorized period for trial and temporary keys.

days       : (word) Days of the authorized period for trial and temporary keys.

idx        : (byte) Index number (0..254)

users      : (byte) Number of users to share the key through the OLM.

            One record for each user. the first primary and the others secondary.

instances  : (byte) Number of instances allowed to run at once into the computer.

keytype    : (byte) Type of Key (0=Trial, 1=Temporal, 2=Permanent, 3=Unregister, 4=UnregisterAll)

values     : (string) Three hexadecimal digits to control several options into your application.

 

Return a integer value with the following meaning:

 

0: No error

1: Key length mismatch

2: Installcode mismatch

3: Validation error

4: AppID mismatch

5: Version mismatch

6: Module mismatch

 

DecodeAppData()

function DecodeAppData(appdata: string; var UsrNam, Comp, Eml, AppNam, AppVer,

 instcode: string; var OtherCod: word): Boolean;

 

This method takes as input a string parameter with the application data read from the local disk, then decrypt, verify it with a internal checksum and decode this string into the following output parameters:

 

UsrNam   : (string) User name.

Comp     : (string) User company.

Eml      : (string) User email.

AppNam   : (string) Application Name.

AppVer   : (string) Application version.

instcode : (string) Installcode saved with the app data.

OtherCod : (word)   OtherCode property

 

Return True if the data is valid.

 

 

DecodeIcode()

function decodeicode(icode: string; var cod_name, cod_cpu, cod_hd, cod_other,

 cod_icode, checksum: word): Boolean;

 

This method takes as input a string parameter "icode" with the InstallCode to be decoded. This input parameter must be in the following format: XXXXXX-XXXXXX-XXXXXX-XXXXXX. Then decrypt and decode this parameter into the following output parameters:

 

checksum  : (word)

cod_cpu   : (word)

cod_hd    : (word)

cod_name  : (word) //User data

cod_other : (word)

cod_icode : (byte)

 

If the calculated checksum match with the decoded checksum then return True else return False.  

For more information see the InstallCode and InstallCodeSources properties.

 

EraseKey()

function EraseKey(Index: byte): Boolean;

Removes the local registration data for the given index.

 

EraseReg()

function EraseReg:boolean;

This method removes all modules and local application data from the local disk.

 

GenRegKey()

function GenRegKey(Values, AICode, enckey: string; Abegindate: TDate;

 Adays, AAppID: word; AUsers, AInstances, AIndex, AKeyKind: byte): string;

 

This method returns a registration key calculated in basis to the given parameters. Not used directly. The methods GenGenericKey() and GenRegularKey() uses it internally.

 

GenGenericKey()

function GenGenericKey(AICode, Values, enckey: string; Abegindate: TDate;

 Adays, AVersionID, AAppID: word; AUsers, AInstances, AIndex,

 KeyType: byte): string;

 

This method returns a generic registration key calculated in basis to the given parameters.

 

Values     : (string) Three hexadecimal chars to control options into the application.

AICode     : (string) Summarized code (Checksum) from the Installcode.

Abegindate : (tdate)  StartDate, date where start the authorized period for trial and temporary keys.

Adays      : (word)   Days of the authorized period for trial and temporary keys.

AVersionID : (word)   VersionID. Value calculated from the version number.

AAppID     : (word)   AppID property.

AUsers     : (byte)   Number of users to share the key through the OLM.

AInstances : (byte)   Number of instances allowed to run at once into the computer.

AIndex     : (byte)   Index number (0..254)

KeyType    : (byte)   Type of Key (0=Trial, 1=Temporal, 2=Permanent, 3=Unregister, 4=UnregisterAll)

 

This method is only used into the KeyGen and RegMonitor utilities.

 

GenRegularKey()

function GenRegularKey(AICode, Values, enckey: string; Abegindate: TDate;

 Adays, AAppID: word; AUsers, AInstances, AIndex, KeyType: byte): string;

 

This method returns a regular registration key calculated in basis to the given parameters.

 

AICode     : (string) Summarized code (Checksum) from the Installcode.

Values     : (string) Three hexadecimal chars to control options into the application.

Abegindate : (tdate)  StartDate, date where start the authorized period for trial and temporary keys.

Adays      : (word)   Days of the authorized period for trial and temporary keys.

AAppID     : (word)   AppID property.

AUsers     : (byte)   Number of users to share the key through the OLM.

AInstances : (byte)   Number of instances allowed to run at once into the computer.

AIndex     : (byte)   Index number (0..254)

KeyType    : (byte)   Type of Key (0=Trial, 1=Temporal, 2=Permanent, 3=Unregister, 4=UnregisterAll)

 

GetCategory()

function GetCategory(Index:word):string;

This method access to the proper record into the OLM, then returns a character with the following meaning:

N: Record Not found

P: Primary record

S: Secondary record

 

GetKeyType()

function GetKeytype(Key:string):byte;

Return the key type from the given "Key" parameter.

(0=Trial, 1=Temporal, 2=Permanent, 3=Unregister, 4=UnregisterAll).

 

GetICode()

procedure GetICode(IsGuest, remov: Boolean; icodesrc: TInstallCodesources; user, company, email: string; Other: word; var icode, InstallCode: string);

 

This method calculates the InstallCode Property from several sources coming from the hard and others according with the value for the InstallCodeSources property. Also return the ICode value as a checksum of all fields into the Installcode value. Below the figure outline it.

 

geticode06

 

See also the ICode, InstallCode and InstallCodeSources properties.

 

 

GetKeyData()

function GetKeyData(Index:byte; var KeyData:TKeyData):boolean;

This method gets the registration data for a given key index and returns True if the operation was successful. The data retrieved from the local registration is returned into the KeyData record.
Below is the definition for the type TKeyData.

 

 TRegStatus = (Unregistered, Moved, Expired, Registered);

 TKeyType = (Trial, Temporal, Permanent, Unregister, UnregisterAll);

 

 TKeyData = record

   Status       : TRegStatus;

   KeyType      : TKeyType;

   Startdate    : TDate;

   EndDate      : TDate;

   Days         : word;

   Users        : byte;

   Instances    : byte;

   Primary      : boolean;

   DateBacked   : boolean;

   TooManyInstances : boolean;

   Values       : string;

   Key          : string;

   ICodeP       : string;

   InstallCodep : string;

 end;

 

Understanding these fields

 

Status:

 Unregistered  : Data do not exists for the given module.

 Expired       : The authorized period finished. For trial and temporary keys. (not active)

 Moved         : The module is marked to be moved to another computer. (not active)

 Registered    : The module is registered and active.

 

KeyType:

 Trial         : The module is registered as trial.

 Temporal      : The module is registered as temporal.

 Permanent     : The module is registered at definitive way.

 Unregister    : The key will remove the registration data for the given key index.

 UnregisterAll : The key will remove all registration data for the application including all registered keys.

 

StartDate       : date where start the authorized period for trial and temporary keys.

EndDate         : Date where finishes the authorized period for a trial or temporal key

Days            : Days of the authorized period for trial and temporary keys.

Users           : Number of users to share the key through the OLM.

Instances       : Number of instances allowed to run at once into the computer.

Primary         : True for a primary registration and False for a secondary  registration.

DateBacked      : True if the system date was turned back.

TooManyInstances: True when the number of instances running on the computer exceed

                         the number of authorized instances.

Values          : Three hexadecimal chars to control options into the application.

Key             : Registration Key.

ICodeP          : Checksum from the Primary InstallCode. Only usable for secondary registrations.

InstllCodeP     : InstallCode from the primary registration. Only usable for secondary registrations.

 

 

In the version 3.0 the RegStatus type was split into the two types TKeyType and TRegStatus defined above. Not all combinations are valid, below is a table for these possible combinations:

 

TKeyType      TRegStatus       Meanings

Trial         Unregistered     N/A (Unregistered mean the lack of registration)

Trial         Moved            Registration marked to be moved to another computer

                              (not functional) not usual for Trial Keys

Trial         Expired          Trial period expired

Trial         Registered       The key is saved and functional

Temporal      Unregistered     N/A (Unregistered mean the lack of registration)

Temporal      Moved            Registration marked to be moved to another computer

                              (not functional)

Temporal      Expired          Temporal period expired

Temporal      Registered       The key is saved and functional

Permanent     Unregistered     N/A (Unregistered mean the lack of registration)

Permanant     Moved            Registration marked to be moved to another computer

                              (not functional)

Permanent     Expired          N/A (permanent do not expire)

Permanent     Registered       The key is saved and functional

Unregister    N/A              The key is intended to delete the registered key for the given index.

UnregisterAll N/A              The key is intended to delete all registered keys for all indexes.

 

 

GetKeyType()

function GetKeytype(Key:string):byte;

Returns the key type for the given Key. Namely:

0=trial,    1=temporal,  2=permanent,   3=unregister,   4=unregisterall

 

GetOnlineDate()

function GetOnlineDate(TimeHost: string): TDateTime;

 

Get from internet the actual datetime. For example:

 

onlinedate := GetOnlineDate('time-a.nist.gov');

 

 

HostFound()

function HostFound(const HostName: string):boolean;

 

Returns True when the given parameter corresponds with a existing web host. e.g.

 

 Ok := HostFound('www.av-soft.com');

 

IsLocal()

Function IsLocal:boolean;

Return True if the application is running at local way and return False if is executed from a remote location into the network.

 

MakeTrial()

function MakeTrial(Index, Users, Instances: byte; Startdate: TDate;

                  Days: word; Values: string): Integer;

This method generates a key of type trial and register it into the registration data according with the given parameters:

  index = key index.

  instances = max concurrent instances allowed.

  startdate = date from where start the trial period.

  days = days for the trial period.

    values = value for the "values" field into the key

 

ReadAppData()

function ReadAppData(update:boolean):boolean;

This method read the local registration data from the local disk. For more information see the section Local Registration Data from the "Registration Keys" topic.

The data read will be fully or partially applied to the properties of the component depending on the parameter passed. For example if you use ReadAppData (True ,..); all the data read will be applied to properties and otherwise only apply the following: UserName, Company and Email. Internally, the component uses this function, but always in the form ReadAppData (False) Using TRUE as if we would be overwriting the same values. Only in the source code of the utility RegMonitor we use True for the update parameter.

 

ReadLastDate()

procedure ReadLastDate;

This method read from the local registration data a date value saved previously the last time that the application runs. If this date is greater than the actual system date (with one day of tolerance to avoid problems with the timezone) the DateBacked property is set to True. Also is read another value (Y/N) and assigned to the DateWarning property. This property is set to True when the date was moved, forward or backward more than 2 days. This may warn you when the date is manipulated perhaps with the intention of use the application illegally. Later you can test these values to execute the OnlineCheckDate() method in order to verify online the date.  See the  Demo1 sample.

 

ReadKeyData()

function ReadKeyData(index:byte):string;

This method reads the registration data for the given index. Decrypt the data and return a string of 87 characters with 5 concatenated fields. namely:

[Registration Key(31)]+[Moved(1)]+[Primary(1)]+[Primary InstallCode(27)]+[LocalInstallCode(27)]

 

Exmple:

 

datacheck03

 

This method is used internally for these methods: GetKeyData(),  OnlineRestorePrimary() and  OnlineRestoreSecondary(). See more information in the Local Registration Data section from the "Basic Concepts" topic.

 

RegisterKey()

function RegisterKey(Key:String):integer;

This method register a key using the key passed as parameter. Saves the key into the local disk together with another data concatenated as explained in the previous section ReadKeyData().

 

ReStart()

procedure ReStart;

This method is used to call again the Start() method. This may be needed to refresh the values for some properties e.g. when the UserName and Company has been changed. (see example 8).

 

Start()

procedure Start;

This method is called only once when the application starts and is used to set up at runtime the values for some properties like InstallCode, ICode, DateBacked, UserName, Company, Email, etc.

 

UserNameFromWindows()

Function UserNameFromWindows: string;

Get and return the current registered user name from Windows.

 

WriteAppData()

procedure WriteAppData;

Saves some registration data shared by the whole application into a data file into the local disk. For more information see the Local Registration Data section from the "Registration Keys" topic.

 

WriteKeyData()

function WriteKeyData(RKey:string):boolean;

Saves a key into the local registration data into the local disk. This must not be used directly into your application. Is used internally into  the component for the methods that saves a key into the registration data, namely: RegisterKey(), OnLineSynch(), OnlineStartTrial(), OnlineExtendTrial(), OnlineRegisterKey, etc.

 

WriteLastDate()

procedure WriteLastDate;

If the actual system date is greater than the LastDate property then this property is updated with the actual system date and saved into the local registration data. At this way the date value for LastDate will be equal to the highest system date ever reached. This value is saved in order to avoid the user move back the system date with the purpose to reutilize an expired trial period. See the DateBacked property.

 

 

METHODS TO ACCESS THE OLM

 

 

Connected()

function Connected:boolean;

Return True if an internet connection is available.

 

OnlineCheckDate()

function OnlineCheckDate(fix:boolean):boolean;

This method verifies the date of the computer compared with that obtained from the Internet. If (fix = true) also synchronizes the date and time from the computer with the Internet. It also stores the date into the LastDate field of the local registration data. See examples 1 to 7.

 

OnlineFullSynch()

function OnlineFullSynch(Index:word):string;

This function copies the registration data from the OLM database to the registration data into the computer. Parameter is passed as the index number. Also, if there is no record in the OLM a new one is created and initialized with a key of type trial using the default values, also if  (Paid = Y) performs the same function as OnlineRenew() and if (Extend = Y) perform the same function as OnlineExtendTrial(). Returns a string with the result of the operation code, '00 'if it was successful.

 

OnlineRequest()

function OnlineRequest(target:string; postdata, enkey2:AnsiString; web:string):AnsiString;

Do no use this function directly into your application. It is used for all function with access to the OLM.

 

OnlineRequestKey()

function OnlineRequestKey(name1, company1, email1, fromname1, fromemail1, values1, subject1, msg1, msg2:String; kind1, index1, users1, inst1, days1 :word):string;

This function is added in version 5 and allow to the user to request a registration key by email to the email address specified by the user. Also are parameters for the names and email addresses of the sender and receiver as well as the subject and message. See the RequestKey example.

 

OnlineRegisterKey()

function OnlineRegisterKey(Key:String):string;

This function registers an application with the registration key passed as parameter. The key and other registration data are stored on the local machine and also into the database of the website in the OLM.

 

 

onlineregisterkey01

Returns a string with the result of the operation code. For more information see Example 4.

 

New functions to start the trial period

In version 6.x we added new functions to start the trial period that are equivalent to existing functions from the previous version 5. We still support the old ones, but recommend the use of new:

 

StartTrialBare() - Equivalent to MakeTrial()

function StartTrialBare(Index, Instances, Days: word; Values: string): Integer;

 

StartTrialBasic() - Equivalent to OnlineGetKeyB()

function StartTrialBasic(Index, Inst, Days: word; values: string): string;

 

StartTrialAdv() - Equivalent to OnlineStartTrial()

function StartTrialBasic(Index, users,  Instances, days: word; values: string): string;

 

 

OnlineStartTrial() - Instead you can use StartTrialAdv()

function OnlineStartTrial(Index,users,instances:byte; days:word; values:string):string;

This function starts the trial period for the given index. It takes as parameters:

 

Index: Key index (0..254);

users: allowed users.

instances: allowed instances

days: days for the trial period

values: values field

 

onlinestarttrial01

Returns a string with the result of the operation code. For more information see Example 4 and 5.

 

OnlineExtendTrial()

function OnlineExtendTrial(Index,users,instances:byte; days:word; values:string):string;

This function extends the trial period for the given index. It takes as parameters the same as seen above in OnlineStartTrial(), only have effect if into the registration of the OLM (Extend = 'Y'). Returns '00' if the operation is done.

 

OnlineGetKeyB()

function OnlineGetKeyB(values:string; kind, Index, days, inst:word):string;

This function starts the trial period for the given index. This uses the basic set of scripts (basic OLM). Its functionality is very similar to the methods OnlineStartTrial() and OnlineExtendTrial() with the difference that here do not include the number of users because the user management can only be done with advanced OLM. For details, see the examples 1 to 5.

 

OnlineGetKeyA()

function OnlineGetKeyA(values:string; kind, Index, days, startdate, usrs, inst:word):string;

This function generates a registration key as the OnlineGetKeyB() does, but using the Advanced OLM, advancedkeymanager.php script. The key is generated using the given parameters but do not modify any data into the OLM or locally. We do not use it into the samples. Is available for you to be used under your own criteria, perhaps to create some kind of key generator.

 

OnlineMovePrimary1()

function OnlineMovePrimary1(index:word):string;

This function is used to mark a primary registration to be moved to another computer. Get all records from the OLM database for the given index having the primary Installcode coincident with that obtained from the computer. This will deactivate the primary registration in the computer and also the associated records for computers that share the same license, sets (Moved = Y) to all these records. Returns a string with the operation code, '00' if it was successful.

 

OnlineMovePrimary2()

function OnlineMovePrimary2(OldIcode:string; index:word):string;

This performs the second step in the process of moving a primary license from one computer to another. This function needs to be passed as a parameter the InstallCode from the old computer besides the number of index. Access the OLM using the script 'advancedolm.php' and generates a new key based on the Installcode from the new computer and leaving unchanged the other parameters (users, instances, startdate, days, kind and values). Save this new key and InstallCode in the record corresponding to this primary computer and modify the secondary records with the new primary Installcode and sets (Moved = N) in all the records involved. Finally store the registration data in the current computer. If you implement the option of moving the registration for your application and allows more than one user per license (users > 1), could also perform the function OnlineSynch() or Synchronize() on the secondary computer to update the registration data premises when the license has moved. Returns a string with the operation code, '00' if it was successful.

 

OnlineMoveSecondary1()

function OnlineMoveSecondary1(index:word):string;

This function is used to mark a secondary registration to be moved to another computer. This access to the record in the OLM database for the given index and the Installcode coincident with that obtained from the computer, then sets (Moved = Y). The record must be secondary. Returns a string with the operation code, '00' if it was successful.

 

OnlineMoveSecondary2()

function OnlineMoveSecondary2(OldIcode:string; index:word):string;

This performs the second step in the process of moving a secondary license from one computer to another. This function needs to be passed as a parameter the InstallCode from the old computer besides the number of index. Get the record corresponding to the old InstallCode and replace it with the one coming from the new computer, then assigns (Moved = N) to activate the license. Returns a string with the operation code, '00' if it was successful.

 

OnlineRestorePrimary()

function OnlineRestorePrimary(index:word):string;

This function restores this primary registration to their original state after performing the function OnlineMovePrimary1(). Access to all OLM records where the Primary InstallCode is coincident with that obtained from the computer, then assigns (Moved = N) for all these records. Returns a string with the operation code, '00' if it was successful.

 

OnlineRestoreSecondary()

function OnlineRestoreSecondary(nmod:word):string;

This function restores this registration secondary to its original state after performing the function OnlineMoveSecondary1(). From the old computer accesses the moved record in the OLM, then assigns (Moved = N). Returns a string with the operation code, '00' if it was successful.

OnlineSynch()

function OnlineSynch(index:word):string;

This function restores the local registration data for the given index from the OLM using the advancedolm.php script. Returns a string with the operation code, '00' if successful.

 

OnlineSynch0()

function OnlineSynch0(Index: word):string;

Almost like OnlineSynch but in this case the function returns only the registration data received from the OLM and not saves it in the app, leaves them to the application. See how to use it in the example 3.

 

OnlineRenew() - Instead you can use RenewSynch(). See the example 2

function OnlineRenew(index:word):string;

This function uses the OLM to generate a new registration key based on the record fields of the OLM, then saves it in the same record and returns the key to the application where it is stored together with the local registration data. Returns a string with the operation code, '00' if it was successful.

 

RenewSynch()

function RenewSynch(Index: word):string;

Almost like OnlineRenew but in this case the function returns only the registration data received from the OLM and not saves it in the app, leaves them to the application. See how to use it in the example 2.

 

OnlineRenew2()

function OnlineRenew2(Index:word):string;

Almost like OnlineRenew but in this case adds to the new period the remaining days of the previous period.

 

OnlineStartSecondary()

function OnLineStartSecondary(icodep:string; index:word):string;

This function creates a secondary registration for the given index. You should also give the InstallCode from the computer that performed the primary registration (icodep). The number of secondary records that can be associated to a primary depends on the users value included in the registration key and also saved as one of the fields into the record. For example, if (users = 4) may only have 3 secondary records thus completing the total of 4. Returns a string with the operation code, '00' if it was successful.

 

OnlineRemoveReg()

function OnlineRemoveReg(nmod:word):string;

This function eliminates the existing records for the given index, either, primary or secondary will be removed. Returns a string with the operation code, '00' if it was successful.

 

OnlineGetRegData()

function OnlineGetRegData(index:word):string;

Read the corresponding record from the OLM using the advancedolm.php script (Adv.OLM) and return all fields into a string using '|' as separator as follow: (username |company |email |exten |paid1 |lastkey |days |keydate |move |instances |users |icsum |icodep |primar |vals |kind |startdate).

This function is used into the RegMonitor utility in order to implement the "Online Registration" tabsheet.

 

OnlineSaveUserData()

function OnlineSaveUserData(name,company,email:String; nmod:word):string;

This method takes the given data into the parameters name, company and email and saves it either, into the local application data  and into the OLM using the advancedolm.php script (Adv.OLM).

 

OnlineSendEmail()

function OnlineSendEmail(index:integer;fromname1,fromemail1,toemail1,subject1,msg1:String):string;This method takes the data passed as parameters and uses them to send an email. You can use tags that will be replaced in the OLM

 

<CR>  will be replaced by #13#12 (carriage return and line feed).

<ICODE> will be replaced by the InstallCode (ICODE field)

<UNAME> will be replaced by the User Name (USERNAME field)

<COMP> will be replaced by the COMPANY field

<OTHER> will be replaced by the OTHER field

<EML> will be replaced by the EMAIL field

 

Synchronize()

function Synchronize(Index:word; verbose;boolean):string;

This function synchronizes the registration data between the OLM and the computer. To the OLM are sent the local registration data and there are compared with to existing and are evaluated to determine which two are most relevant, then, if local data are more relevant is made a synchronization (Local -> OLM) otherwise is a made a synchronization (OLM -> Local). Also, if necessary this performs the same functions as OnlineRenew() and OnlineExtendTrial(). The parameters passed are:

 

Index: Determines the keys to be synchronized. For example if (index = 2) will synchronize the keys corresponding to the indexes 0, 1 and 2.

 

Verbose: If False, returns a string with the operation codes (one for each key) e.g. ('200 | 366 | 000 '). Each code has three digits.

The first indicates the type of operation has been attempted in the OLM to know:

   0: There is no operation,

   2: Operation equivalent OnlineRenew (). It renews the key for being (Paid = Y).

   3: Primary Synchronization license (Local -> OLM)

   4: Synchronizing primary license (OLM -> Local)

   5: Synchronizing secondary license (OLM -> Local)

 

The two remaining digits, 2 and 3 are the result of the operation, ('00 '.. '11') to those returned by operations in the local computer and ('50 '.. '72') occurred in the OLM . See the Error2Str() function below.

 

 

 

UTILITARIAN METHODS

 

These are some methods and functions added in this version to facilitate some common tasks when dealing with error messages, the Values field, the system date and others.

 

FixSystemDate()

procedure fixsystemdate(dat:tdatetime);

It takes as parameter a date that is used to change the date of the computer.

 

 

Methods to be used with the Values field:

These two methods deals with the Values field. The Values field takes three nibbles 1.5 byte (e.g. '000', 'ABF', etc). This field could be used to control several things into the application. By example you could use a nibble expressed as a binary representation (four 1/0 or True/False values) to enable/disable up to four features into your application. So the IsValueOn() method return one of these four values True/False from the given parameters. Also you could use other nibble converted into a integer value (0..15), or all three nibbles as a whole integer value (0..4095) in order to control other kind of feature e.g. to control the level of access into a database, see the Values2Num() method and demo1.

 

IsValueOn()

function IsValueOn(Values:string; nibble, digit:byte):boolean;

Takes three parameters; the Values field, the nibble (1..3) and the digit (0..3) and return True or False according with the status of the implied bit into the Values field.

 

Values2Num()

function Values2Num(Values:string; nibble:byte):integer;

Takes two parameters; the Values field and the selected nibble. If nibble is 0 then return the three nibbles as a whole integer value.

 

In the image below you can see some samples using these two methods.

 

values01

 

Methods to prepare error messages:

The following two methods are intended to deal with registration status messages and error messages. The source code is included, so if you like you can create your own functions in order to customize it.

 

Status2Str()

function Status2Str(KeyData:TKeyData):string;

Return a string with a message about the status of the KeyData record passed as parameter. Below is the source code.

 

function TAVLockS4.Status2Str(KeyData:TKeyData):string;

var s:string;

begin

 s:='';

 if KeyData.DateBacked then s:='Bad system date'

 else

 case KeyData.KeyType of

   Trial: s:=s+'Trial';

   Temporal: s:=s+'Temporary';

   Permanent: s:=s+'Registered';

 end;

 case KeyData.Status of

   Unregistered: s:='Unregistered';

   Expired: s:=s+'-Expired';

   Moved: s:=s+'-Moved';

   Registered:

     if (KeyData.KeyType in[Trial,Temporal])

     then s:=s+', '+inttostr(KeyData.DaysLeft)+' days left';

 end;

 result:=s;

end;

 

 

 

Error2Str()

function Error2Str(err:string):string;

Return a string with the error message for the given err parameter which must take two decimal digits (e.g. '01', '02', etc).

When the value is between '00' and '11' then this is coming from the online method into the component (e.g. OnlineStartTrial(), OnlineRenew(), etc),  but when the value is between '50' and '72' this is a response coming from the OLM. Below is the source code.

 

function Error2Str(err:string):string;

var n,l:integer;

 ok:boolean;

  s,res:string;

begin

 result:=''; s:='';

 l:=length(err);

 ok:= (l in[2,3]) and isdigit(err);

 if ok then begin

   if (l=3) then begin

     res:='('+err[1]+') ';

     err:=copy(err,2,2);

   end;

 end;

 if not ok and (copy(err,1,2)='99') then begin

   result := copy(err,3,255);

   exit;

 end;

 if ok then n:=strtoint(err);

 if (n in[0,50]) then exit;

 if (n in [1..10]) then result:='Error: '

 else if (n in [51..73]) then result:= result+'OLM ERROR: ';

 case n of

   1 : s:='Could not write key data';

   2 : s:='Bad response from OLM request';

   3 : s:='Unregistered';

   4 : s:='Invalid Registration Key';

   5 : s:='Local Data not Primary or Moved';

   6 : s:='Local Data not Primary or not Moved';

   7 : s:='Local Data Primary or Moved';

   8 : s:='Local Data Primary or not Moved';

   9 : s:='Local Data is Primary';

  10 : s:='Local Data is Secondary';

  11 : s:='Could not delete local key data';

 

  51 : s:='VALUES_POSTED_COUNT_MISMATCH';

  52 : s:='NO_DATA_POSTE';

  53 : s:='ICODE_LENGTH_MISMATCH';

  54 : s:='ICSUM_LENGTH_MISMATCH';

  55 : s:='SECONDARY_LINKED_TO_SECONDARY';

  56 : s:='PRIMARY_NOT_EXISTS';

  57 : s:='KEY_LENGTH_MISMATCH';

  58 : s:='COULD_NOT_UPDATE_RECORDS';

  59 : s:='COULD_NOT_CONNECT_TO_DATABASE';

  60 : s:='NOT_EXTENSION_ALLOWED';

  61 : s:='NOT_MORE_USERS_ALLOWED';

  62 : s:='COULD_NOT_CONNECT_TO_DATABASE';

  63 : s:='NOT_PAID';

  64 : s:='COULD_NOT_DELETE_RECORDS';

  65 : s:='RECORD_ALREADY_EXISTS';

  66 : s:='RECORD_NOT_EXISTS';

  67 : s:='RECORD_NOT_SAVED';

  68 : s:='RECORD_IS_NOT_PRIMARY';

  69 : s:='RECORD_IS_NOT_SECONDARY';

  70 : s:='RECORD_IS_NOT_MOVED';

  71 : s:='RECORD_IS_MOVED';

  72 : s:='COUNT_OF_RECORDS_IS_ZERO';

  73 : s:='UNKNOWN_OLM_ERROR';

  else s:='Unknown error';

 end;

 result:=result+s;

end;

 

ErrorMessages()

function ErrorMessages(arr:TArrStr):string;

It is used internally by the Synchronize method() to prepare a verbose message as operation result. For each code returned applies the Error2Str() function and concatenates it to the function result.

 

 

function ErrorMessages(arr:TArrStr):string;

var i,n:integer;

   s:string;

begin

 result:='';

 n:=High(Arr);

 for i:=0 to n do begin

   s:=Error2Str(Arr[i]);

   if (s<>'') then  result:=result+inttostr(i)+': '+s+#13#10;

 end;

end;

 

I tried to make this help as clear and complete as possible, however they may have some issues not covered by this documentation. If you think I have missed something, or found errors, or have any idea that might be useful to improve this help, please let me know.

 


  Alcides Valega

Author of AVLock SIMPLE