Class tIceLock (unit IceLock)

Inherits from

TComponent

*************************************************************************) (*** ***) (*** Here it is!!! The tIceLock Component!! ***) (*** ***) (

Constructors


constructor Create(AOwner: TComponent);

The obvious create/destroy thingies.


Functions

function BuildUserKey(Name : NameString; IsDemo : boolean) : KeyString;

nuff said } { Creates a key, based on ProgKey1/ProgKey2/Name, returns KeyString

============================== >> function tIceLock.


Function CheckKey(n : NameString;k : KeyString) : boolean;

Checks a Name/Key combination, returns boolean result

============================== >> Function tIceLock.


function GetKey : KeyString;

Get's the current value of UserName or UserKey

============================== >> function tIceLock.


function GetName : NameString;

============================== >> function tIceLock.

function LoadKeyFile : Integer;

============================== >> function tIceLock.

function PutKey(name : NameString; Key : KeyString) : integer;

PutKey attempts to put Name/key into Username/Userkey, returns result ieOkay if successful, ieInvalidKey for invalid key, If the key is invalid Username/Userkey are not change

============================== >> function tIceLock.


function SaveKeyFile : Integer;

These two functions save/load current key to the currently selected fKeyFileName Property.

function CalcCRCBuffer(CRC_Value: LONGINT; cBuffer: CRCBuffType ): LONGINT;

============================== >> function tIceLock.

procedure EncryptRecord(p : Pointer);

Procedures used internally only !

============================== >> procedure tIceLock.


function GetExpirationDate: TDateTime;

+++============================== >> function tIceLock.

function GetHDSerialNumber: LongInt;

+++ This function gets the Hard Disk Serial Number

+++============================== >> function tIceLock.


function HexLongInt(L : LongInt) : KeyString;

============================== >> function tIceLock.

procedure InitProgramKeys;

============================== >> procedure tIceLock.

procedure SetExpirationDate(ed: TDateTime);

+++============================== >> procedure tIceLock.

procedure SetIce1(s : sstring);

Number of days for demo license } { Procedures used to set Private variables

+++ DOS3Call } {============================== >> procedure tIceLock.


procedure SetIce2(s : sstring);

============================== >> procedure tIceLock.

procedure SetKeyFileName(fn : sstring);

============================== >> procedure tIceLock.

procedure SetProgKey1(l : LongInt);

============================== >> procedure tIceLock.

procedure SetProgKey2(l : LongInt);

============================== >> procedure tIceLock.

procedure SetSeedVal1(l : LongInt);

============================== >> procedure tIceLock.

procedure SetSeedVal2(l : LongInt);

============================== >> procedure tIceLock.

Properties

property DemoLicense : Boolean


property ExpirationDate : tDateTime


property IceSeed1 : LongInt


property IceSeed2 : LongInt


property IceString1 : sstring

Note: IceString1, IceString2, IceSeed1, IceSeed2 Must be alphabetically less that ProgramKey1 and ProgramKey2!! Delphi sets these values, from information created at design time, in the Object Inspector, in Alpha Order.

property IceString2 : sstring


property KeyFile : sstring


property ProgramKey1 : LongInt


property ProgramKey2 : LongInt


property TrialDays : integer


Events

Variables

IsRegistered : boolean;

Holds the last ioresult from save/loadkeyfile

LastIoResult : integer;

End Protected declarations

fDemoLicense : Boolean;

Set by LoadKeyFile, or PutKey

fExpirationDate : TDateTime;

+++ Set by LoadKeyFile

fIce1 : sstring;

* The following fields are available for design time modification, via the object inspector.

fIce2 : sstring;


fKeyFileName : sstring;

Kind of obvious, this hold the file name for your keys, again allows different key names for different applications

fProgKey1 : LongInt;

Created, based on Ice1/Ice2, also the user can override these values via the object inspector or the corresponding Properties.

fProgKey2 : LongInt;


fSeedVal1 : LongInt;

Another level of security, these are the seed values, used to create the ProgKeys, based on Ice, you can changes these also.

fSeedVal2 : LongInt;


fTrialDays : Integer;

+++ Set by LoadKeyFile or SetExpirationDate

Seed : LongInt;

* The following Private fields/procedure, are really private!, ie: no direct access at all

UserKey : KeyString;

Set by LoadKeyFile, or PutKey

UserName : NameString;

Set in Create


Constructors


constructor Create(AOwner: TComponent);

The obvious create/destroy thingies....

============================== >> constructor tIceLock.Create(AOwner: TComponent); > Description : Called when tIceLock component is created, initializes variables. ==============================


Functions


function BuildUserKey(Name : NameString; IsDemo : boolean) : KeyString;

nuff said } { Creates a key, based on ProgKey1/ProgKey2/Name, returns KeyString

============================== >> function tIceLock.BuildUserKey(Name : NameString) : KeyString; > Description : Creates a Key from the passed Name. If DemoLicense : then a temporary key is created. > Input : Name - the users name > Output : a Key ==============================


Function CheckKey(n : NameString;k : KeyString) : boolean;

Checks a Name/Key combination, returns boolean result

============================== >> Function tIceLock.CheckKey(n : NameString;k : KeyString) : boolean; > Description : Verified that the key (k) is valid for name (n) > Input : a name and key > Output : Boolean result, true if good key : Also Sets DemoLicense : depending on which matches. If ltTemporary, then : the TrialDays property is used to determine the : expiration date. ==============================


function GetKey : KeyString;

Get's the current value of UserName or UserKey

============================== >> function tIceLock.GetKey : KeyString; > Description : Gets the current key stored in UserKey ==============================


function GetName : NameString;

============================== >> function tIceLock.GetName : NameString; > Description : Gets the current name in UserName ==============================


function LoadKeyFile : Integer;

============================== >> function tIceLock.LoadKeyFile : Integer; > Description : Attempts to load the current key to a file. > Input : none > Output : Returns ieOkay for success, ieInvalid for invalid key, ieFileError if there is some problem creating/reading the file or ieNotSameHD if this key file was copied from somewhere. If the result if ieFileError, your program can check the value of LastIoResult to get the error code. ==============================


function PutKey(name : NameString; Key : KeyString) : integer;

PutKey attempts to put Name/key into Username/Userkey, returns result ieOkay if successful, ieInvalidKey for invalid key, If the key is invalid Username/Userkey are not change

============================== >> function tIceLock.PutKey(name : NameString; Key : KeyString) : integer; > Description : Attempts to store name and Key in UserName and Userkey > Input : a name and key.. > Output : Returns error code ieOkay if successful, ieInvalid for invalid keys. ==============================


function SaveKeyFile : Integer;

These two functions save/load current key to the currently selected fKeyFileName Property..

============================== >> function tIceLock.SaveKeyFile : Integer; > Description : Attempt to save the current key to a file. > Input : none > Output : Returns ieOkay for success, ieInvalid for invalid key, or ieFileError if there is some problem creating/writting to file. If the result if ieFileError, your program can check the value of LastIoResult to get the error code. ==============================


function CalcCRCBuffer(CRC_Value: LONGINT; cBuffer: CRCBuffType ): LONGINT;

============================== >> function tIceLock.CalcCRCBuffer(CRC_Value: LONGINT; > Description : Calculates a CRC value, for a CRC buffer. > Input : CRC_Value - This seed value for gen. CRC's cBuffer - the buffer to calculate > Output : Returns a longint CRC value. ==============================


procedure EncryptRecord(p : Pointer);

Procedures used internally only !

============================== >> procedure tIceLock.EncryptRecord(p : Pointer); > Description : Encrypts (masks) the record, before saving to a file. You may very well wish to change the values in MasterKey, for added security > Input : pointer to an IceArray > Output : Nothing, it directly modified the data via 'p'. ==============================


function GetExpirationDate: TDateTime;

+++============================== >> function tIceLock.GetExpirationDate: TDateTime; > Description : Allows user to recover expiration date. ==============================


function GetHDSerialNumber: LongInt;

+++ This function gets the Hard Disk Serial Number

+++============================== >> function tIceLock.GetHDSerialNumber: LongInt; > Description : Get the Serial Number of the Hard Disk where the Key File lives. > Input : none > Output : Returns Serial Number of disk where is fKeyFileName if success or -1 on error. > Notes : This only returns SerialNumber under Win 95/NT, for : win 3.1, I am using GetWinFlags which returns a LongInt : that contains CPU and Mode information. Not as good, but : far more reliable than trying to query the HD information : from Win 3.1 ==============================


function HexLongInt(L : LongInt) : KeyString;

============================== >> function tIceLock.HexLongInt(L : LongInt) : KeyString; > Description : Convert a longint to a KeyString > Input : LongInteger > Output : KeyString ($ABFF...etc) ==============================


procedure InitProgramKeys;

============================== >> procedure tIceLock.InitProgramKeys; > Description : Initializes program keys, based on the values of Ice1/ progkey1 and Ice2/Progkey2 > Input : None works only on object properties ==============================


procedure SetExpirationDate(ed: TDateTime);

+++============================== >> procedure tIceLock.SetExpirationDate(ed: TDateTime); > Description : Allows user to specify an expiration date, sets LicenseType to ltTemporary. ==============================


procedure SetIce1(s : sstring);

Number of days for demo license } { Procedures used to set Private variables

+++ DOS3Call } {============================== >> procedure tIceLock.SetIce1(s : string); > Description : Set's value for fIce1, then re-inits the program keys based on the new value. Truncates passed string to 70 Characters. ==============================


procedure SetIce2(s : sstring);

============================== >> procedure tIceLock.SetIce2(s : string); > Description : See SetIce1 ==============================


procedure SetKeyFileName(fn : sstring);

============================== >> procedure tIceLock.SetKeyFileName(fn : string); > Description : Sets the value for the KeyFileName. Should be set once at design-time... Remember when you create registration keys, the filename must match! ==============================


procedure SetProgKey1(l : LongInt);

============================== >> procedure tIceLock.SetProgKey1(l : LongInt); > Description : This allows the programmer to set an absolute value for the Program keys. Note, if you do this, you MUST make sure to create keys using this ProgramKey..otherwise you'lL be creating useless keys!! Also, if you change either Ice or SeedVal's (which call InitProgramKeys), your changes will be erased! This may be usefull to confound hackers...maybe set values a few times, then change an IceString.... This could be very frustrating, hacking the ASM code... ==============================


procedure SetProgKey2(l : LongInt);

============================== >> procedure tIceLock.SetProgKey2(l : LongInt); > Description : see SetProgKey1 ==============================


procedure SetSeedVal1(l : LongInt);

============================== >> procedure tIceLock.SetSeedVal1(l : LongInt); > Description : This value is used to seed the CRC creation process with a unique value.. Also re-inits the ProgramKeys using the new value. ==============================


procedure SetSeedVal2(l : LongInt);

============================== >> procedure tIceLock.SetSeedVal2(l : LongInt); > Description : see SetSeedVal1 ==============================


Properties


property DemoLicense : Boolean


property ExpirationDate : tDateTime


property IceSeed1 : LongInt


property IceSeed2 : LongInt


property IceString1 : sstring

Note: IceString1, IceString2, IceSeed1, IceSeed2 Must be alphabetically less that ProgramKey1 and ProgramKey2!! Delphi sets these values, from information created at design time, in the Object Inspector, in Alpha Order. ....anytime you set any Ice value, the component re-initializes the Program Keys....so if they came first (alpha-wise), any changes you made during design time, would not stick!! This should keep things properly synchronised..


property IceString2 : sstring


property KeyFile : sstring


property ProgramKey1 : LongInt


property ProgramKey2 : LongInt


property TrialDays : integer


Events


Variables


IsRegistered : boolean;

Holds the last ioresult from save/loadkeyfile


LastIoResult : integer;

End Protected declarations


fDemoLicense : Boolean;

Set by LoadKeyFile, or PutKey


fExpirationDate : TDateTime;

+++ Set by LoadKeyFile


fIce1 : sstring;

* The following fields are available for design time modification, via the object inspector. Note that they are all read directly from the variable, but written using the appropriate Set procedure **) { Ice1/Ice2, these two are character strings used to build the corresponding ProgKeys, which identify the program that the key belongs to. These allow you to create keys for specific application. Note that these keys will be truncated to 70 characters.


fIce2 : sstring;


fKeyFileName : sstring;

Kind of obvious, this hold the file name for your keys, again allows different key names for different applications


fProgKey1 : LongInt;

Created, based on Ice1/Ice2, also the user can override these values via the object inspector or the corresponding Properties. This allows ANOTHER level of security, in that you could define them anywhere in your code, multiple times...etc... BUT!!! You must make sure that they are the same when you generate keys for your registered users!! Otherwise, you'll be giving them bogus keys!!!!


fProgKey2 : LongInt;


fSeedVal1 : LongInt;

Another level of security, these are the seed values, used to create the ProgKeys, based on Ice, you can changes these also..


fSeedVal2 : LongInt;


fTrialDays : Integer;

+++ Set by LoadKeyFile or SetExpirationDate


Seed : LongInt;

* The following Private fields/procedure, are really private!, ie: no direct access at all


UserKey : KeyString;

Set by LoadKeyFile, or PutKey


UserName : NameString;

Set in Create