Class tIceLock (unit IceLock) |
TComponent
*************************************************************************) (*** ***) (*** Here it is!!! The tIceLock Component!! ***) (*** ***) (
Constructors |
Functions |
============================== >> function tIceLock.
============================== >> Function tIceLock.
============================== >> function tIceLock.
============================== >> function tIceLock.
============================== >> procedure tIceLock.
+++============================== >> function tIceLock.
+++ DOS3Call } {============================== >> procedure tIceLock.
Properties |
Events |
Variables |
Constructors |
The obvious create/destroy thingies....
============================== >> constructor tIceLock.Create(AOwner: TComponent); > Description : Called when tIceLock component is created, initializes variables. ==============================
Functions |
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 ==============================
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. ==============================
Get's the current value of UserName or UserKey
============================== >> function tIceLock.GetKey : KeyString; > Description : Gets the current key stored in UserKey ==============================
============================== >> function tIceLock.GetName : NameString; > Description : Gets the current name in UserName ==============================
============================== >> 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. ==============================
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. ==============================
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 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. ==============================
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 tIceLock.GetExpirationDate: TDateTime; > Description : Allows user to recover expiration date. ==============================
+++ 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 tIceLock.HexLongInt(L : LongInt) : KeyString; > Description : Convert a longint to a KeyString > Input : LongInteger > Output : KeyString ($ABFF...etc) ==============================
============================== >> 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 tIceLock.SetExpirationDate(ed: TDateTime); > Description : Allows user to specify an expiration date, sets LicenseType to ltTemporary. ==============================
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 tIceLock.SetIce2(s : string); > Description : See SetIce1 ==============================
============================== >> 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 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 tIceLock.SetProgKey2(l : LongInt); > Description : see SetProgKey1 ==============================
============================== >> 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 tIceLock.SetSeedVal2(l : LongInt); > Description : see SetSeedVal1 ==============================
Properties |
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..
Events |
Variables |
Holds the last ioresult from save/loadkeyfile
End Protected declarations
Set by LoadKeyFile, or PutKey
+++ Set by LoadKeyFile
* 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.
Kind of obvious, this hold the file name for your keys, again allows different key names for different applications
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!!!!
Another level of security, these are the seed values, used to create the ProgKeys, based on Ice, you can changes these also..
+++ Set by LoadKeyFile or SetExpirationDate
* The following Private fields/procedure, are really private!, ie: no direct access at all
Set by LoadKeyFile, or PutKey
Set in Create