Overview

OnGuard is a library of components, classes, and routines that allow you to protect your applications after they are released to the public. Using OnGuard, you could release an application that is partially functional so that users can try it. When a user is ready to purchase the fully functional application, you supply a release code to unlock all of the features (or the subset that the user is purchasing). You can make your application readily available to a large number of potential users, but still protect your investment. Application protection is accomplished through the use of keys to lock or restrict one or more features of an application and several types of release codes (or access codes) to enable them.

Copyright © 1997 TurboPower Software Co.


Contents

Overview ››

OnGuard is a library of components, classes, and routines that allow you to protect your applications after they are released to the public. Using OnGuard, you could release an application that is partially functional so that users can try it. When a user is ready to purchase the fully functional application, you supply a release code to unlock all of the features (or the subset that the user is purchasing). You can make your application readily available to a large number of potential users, but still protect your investment. Application protection is accomplished through the use of keys to lock or restrict one or more features of an application and several types of release codes (or access codes) to enable them.

Keys and Release Codes

TOgMakeKeys Component TOgMakeKeys_Component

TOgMakeCodes Component TOgMakeCodes_Component

Release Code Components

TOgCodeBase Class TOgCodeBase_Class

TOgDateCode Component TOgDateCode_Component

TOgDaysCode Component TOgDaysCode_Component

TOgNetCode Component TOgNetCode_Component

TOgRegistrationCode Component TOgRegistrationCode_Component

TOgSerialNumberCode Component TOgSerialNumberCode_Component

TOgSpecialCode Component TOgSpecialCode_Component

TOgUsageCode Component TOgUsageCode_Component

Detecting Changes to an EXE

TOgProtectExe Component TOgProtectExe_Component

Single Instance Applications

OgFirst Unit OgFirst_Unit

Low-Level Routines

API Reference API_Reference


Classes

TOgCodeBase Class TOgCodeBase_Class


TOgCodeBase Class

Classes ››

See also: properties TOgCodeBase_Properties>prop, events TOgCodeBase_Events>event, methods TOgCodeBase_Methods>meth

The TOgCodeBase class is the ancestor class for the other "release code" components. It implements several properties and methods that are common for all of its descendants.


TOgCodeBase Events

Classes ›› TOgCodeBase Class ››

OnChecked TOgCodeBase.OnChecked>main

OnGetKey TOgCodeBase.OnGetKey>main

OnGetCode TOgCodeBase.OnGetCode>main

OnGetModifier TOgCodeBase.OnGetModifier>main


TOgCodeBase.OnChecked

Classes ›› TOgCodeBase Class ›› TOgCodeBase Events ››

property TOgCodeBase TOgCodeBase_Class>main.OnChecked : TCheckedCodeEvent

TCheckedCodeEvent = procedure(Sender : TObject; Status : TCodeStatus TOgCodeBase.CheckCode) of object;

OnChecked defines an event handler that is called after the release code is checked.

Sender is the instance of the release code component. Status is the value returned by a call to CheckCode.

See also: CheckCode TOgCodeBase.CheckCode


TOgCodeBase.OnGetCode

Classes ›› TOgCodeBase Class ›› TOgCodeBase Events ››

property TOgCodeBase TOgCodeBase_Class>main.OnGetCode : TGetCodeEvent

TGetCodeEvent = procedure(Sender : TObject; var Code : TCode TOgMakeCodes.Code>main) of object;

OnGetCode defines an event handler that is called to get the release code.

Sender is the instance of the release code component. Code is the TCode TOgMakeCodes.Code>main value associated with this component. Release codes are normally stored in a file or the registry. In some cases, the release code can be stored in the resource. To do this, set the StoreCode property to True.

See also: Code TOgCodeBase.Code, StoreCode TOgCodeBase.StoreCode


TOgCodeBase.OnGetKey

Classes ›› TOgCodeBase Class ›› TOgCodeBase Events ››

property TOgCodeBase TOgCodeBase_Class>main.OnGetKey : TGetKeyEvent

TGetKeyEvent = procedure(Sender : TObject; var Key : TKey TOgMakeKeys.Key>main) of object;

OnGetKey defines an event handler that is called to get the key.

Sender is the instance of the release code component.

The key should always be stored as a constant in the application and never stored in the form, a file, or the registry. Putting the key anywhere except in the application increases the chances that someone will find and be able to use it to decode the release code.


TOgCodeBase.OnGetModifier

Classes ›› TOgCodeBase Class ›› TOgCodeBase Events ››

property TOgCodeBase TOgCodeBase_Class>main.OnGetModifier : TGetModifierEvent

TGetModifierEvent = procedure(Sender : TObject; var Value : LongInt) of object;

OnGetModifier defines an event handler that is called to get the modifier.

Sender is the instance of the release code component. Value is the modifier that is used to sign the key. Modifier is normally generated as needed, but can be stored on the stream with the form if the StoreModifier property is True.

See also: Modifier TOgCodeBase.Modifier, StoreModifier TOgCodeBase.StoreModifier


TOgCodeBase Methods

Classes ›› TOgCodeBase Class ››

CheckCode TOgCodeBase.CheckCode>main

IsCodeValid TOgCodeBase.IsCodeValid>main


TOgCodeBase.CheckCode

Classes ›› TOgCodeBase Class ›› TOgCodeBase Methods ››

function TOgCodeBase TOgCodeBase_Class>main.CheckCode(Report : Boolean) : TCodeStatus; virtual; abstract;

TCodeStatus = (ogValidCode, ogInvalidCode, ogPastEndDate, ogDayCountUsed, ogRunCountUsed, ogNetCountUsed, ogCodeExpired);

CheckCode checks for a valid release code.

CheckCode is defined as virtual and abstract, which means that each descendant component overrides it to provide the necessary code to validate and test the release code obtained through the Code property. If Report is True, the result of the test is reported by triggering the OnChecked TOgCodeBase.OnChecked event. If Report is False, you must check the function result.

CheckCode requires several pieces of information, which it obtains by triggering event handlers that you define. The normal sequence of events performed by CheckCode is:

1. Trigger the OnGetKey TOgCodeBase.OnGetKey event to get the key used to encode and decode the release code. The key should always be embedded in the application as a constant.

2. Trigger the OnGetCode TOgCodeBase.OnGetCode event to get the release code. The release code is normally stored in the registry or an INI file.

3. Trigger the OnGetModifier TOgCodeBase.OnGetModifier event to get the key modifier. The modifier can be stored as a constant in the application, stored in the registry or INI file, or generated when it is needed.

4. Apply the modifier to the key.

5. Test the release code to see if it is valid.

6. Test the release code to see if it has expired. The details of this test depend on the type of release code.

The result of calling CheckCode is one of the following values:

ogValidCode | The release code is valid.
ogInvalidCode | The release code is invalid (the internal integrity check failed).
ogPastEndDate | The ending date has past.
ogDayCountUsed | The authorized days have been used.
ogRunCountUsed | The authorized runs have been used.
ogNetCountUsed | The number of authorized users has been exceeded.
ogCodeExpired | The expiration date has been reached.

See also: AutoCheck TOgCodeBase.AutoCheck, OnChecked TOgCodeBase.OnChecked, OnGetCode TOgCodeBase.OnGetCode, OnGetKey TOgCodeBase.OnGetKey, OnGetModifier TOgCodeBase.OnGetModifier


TOgCodeBase.IsCodeValid

Classes ›› TOgCodeBase Class ›› TOgCodeBase Methods ››

function TOgCodeBase TOgCodeBase_Class>main.IsCodeValid : Boolean;

IsCodeValid tests to see if the release code is valid.

IsCodeValid calls the CheckCode method and tests its result to see if the release code is valid. It returns True if the code is valid, otherwise False. Descendent components decode the release code and test to see if the signature value (the magic value as defined in the TCode TOgMakeCodes.Code>main record) is still valid.

You might need to perform additional tests to ensure that the data used to create the release code was not altered. For example, you could test whether the text string used to create a Simple Registration release code was altered. Since the string is not part of the release code (only a number derived from the string is embedded into the code), you cannot compare it to what is stored in the release code. You must create a temporary release code using the text string and the same expiration date and then compare the temporary release code to the stored one. If they don’t match, someone has altered the text string.

See also: CheckCode TOgCodeBase.CheckCode


TOgCodeBase Properties

Classes ›› TOgCodeBase Class ››

AutoCheck TOgCodeBase.AutoCheck>main

Code TOgCodeBase.Code>main

Modifier TOgCodeBase.Modifier>main

StoreCode TOgCodeBase.StoreCode>main

StoreModifier TOgCodeBase.StoreModifier>main


TOgCodeBase.AutoCheck

Classes ›› TOgCodeBase Class ›› TOgCodeBase Properties ››

property TOgCodeBase TOgCodeBase_Class>main.AutoCheck : Boolean

Default: False

AutoCheck determines whether CheckCode is called automatically.

If AutoCheck is True, CheckCode is automatically called after the form containing this component is loaded. If AutoCheck is False, you are responsible for calling CheckCode to determine the component status.

See also: CheckCode TOgCodeBase.CheckCode


TOgCodeBase.Code

Classes ›› TOgCodeBase Class ›› TOgCodeBase Properties ››

property TOgCodeBase TOgCodeBase_Class>main.Code : string

Code is the release code.

Code is normally generated by another program, encoded using the application’s key, and given to the user to enter into the application where it is decoded and validated. The behavior of the application when a code is entered is entirely up to you, the designer, and is also determined to some extent by the type of code being used.

Code is published as needed by descendent components.

See also: OnGetCode TOgCodeBase.OnGetCode, StoreCode TOgCodeBase.StoreCode


TOgCodeBase.Modifier

Classes ›› TOgCodeBase Class ›› TOgCodeBase Properties ››

property TOgCodeBase TOgCodeBase_Class>main.Modifier : LongInt

Modifier is used to sign the key.

If Modifier is equal to 0, the key is not altered. If Modifier is not equal to 0, it is used to sign the key. Modifier is normally generated as needed, but can be stored on the stream with the form if the StoreModifier property is True.

See also: OnGetModifier TOgCodeBase.OnGetModifier, StoreModifier TOgCodeBase.StoreModifier


TOgCodeBase.StoreCode

Classes ›› TOgCodeBase Class ›› TOgCodeBase Properties ››

property TOgCodeBase TOgCodeBase_Class>main.StoreCode : Boolean

Default: False

StoreCode determines whether the release code is stored in the resource file.

StoreCode is published as needed by descendants.

See also: Code TOgCodeBase.Code, OnGetCode TOgCodeBase.OnGetCode


TOgCodeBase.StoreModifier

Classes ›› TOgCodeBase Class ›› TOgCodeBase Properties ››

property TOgCodeBase TOgCodeBase_Class>main.StoreModifier : Boolean

Default: False

StoreModifier determines whether the modifier is stored in the resource file.

See also: Modifier, TOgCodeBase.Modifier OnGetModifier TOgCodeBase.OnGetModifier


Components

TOgDateCode Component TOgDateCode_Component

TOgDaysCode Component TOgDaysCode_Component

TOgMakeCodes Component TOgMakeCodes_Component

TOgMakeKeys Component TOgMakeKeys_Component

TOgNetCode Component TOgNetCode_Component

TOgProtectExe Component

TOgRegistrationCode Component TOgRegistrationCode_Component

TOgSerialNumberCode Component TOgSerialNumberCode_Component

TOgSpecialCode Component TOgSpecialCode_Component

TOgUsageCode Component TOgUsageCode_Component


TOgDateCode Component

Components ››

See also: properties TOgDateCode_Properties>prop, events TOgDateCode_Events>event, methods TOgDateCode_Methods>meth

TOgDateCode implements a Start/End Date release code. Use this release code when you need to limit the amount of time that an application (or specific features of an application) can be used. Both a start date and an end date are encoded into this release code. This allows you to detect a change to the computer’s clock that results in a date outside of the date range or an attempt to alter the registry or INI file entry.


TOgDateCode Events

Components ›› TOgDateCode Component ››

OnChecked TOgCodeBase.OnChecked>main

OnGetKey TOgCodeBase.OnGetKey>main

OnGetCode TOgCodeBase.OnGetCode>main

OnGetModifier TOgCodeBase.OnGetModifier>main


TOgDateCode Methods

Components ›› TOgDateCode Component ››

CheckCode TOgCodeBase.CheckCode>main

GetValue TOgDateCode.GetValue>main

IsCodeValid TOgCodeBase.IsCodeValid>main


TOgDateCode.GetValue

Components ›› TOgDateCode Component ›› TOgDateCode Methods ››

function TOgDateCode TOgDateCode_Component>main.GetValue : TDateTime;

GetValue returns the end date embedded in the release code.

The returned value is a Delphi TDateTime value.


TOgDateCode Properties

Components ›› TOgDateCode Component ››

AutoCheck TOgCodeBase.AutoCheck>main

Code TOgCodeBase.Code>main

Modifier TOgCodeBase.Modifier>main

StoreCode TOgCodeBase.StoreCode>main

StoreModifier TOgCodeBase.StoreModifier>main


TOgDaysCode Component

Components ››

See also: properties TOgDaysCode_Properties>prop, events TOgDaysCode_Events>event, methods TOgDaysCode_Methods>meth

TOgDaysCode implements a Number of Days Used release code. This release code limits the number of days that an application (or specific features) can be used. The application can be run an unlimited number of times each day.


TOgDaysCode Events

Components ›› TOgDaysCode Component ››

OnChangeCode TOgDaysCode.OnChangeCode>main

OnChecked TOgCodeBase.OnChecked>main

OnGetKey TOgCodeBase.OnGetKey>main

OnGetCode TOgCodeBase.OnGetCode>main

OnGetModifier TOgCodeBase.OnGetModifier>main


TOgDaysCode.OnChangeCode

Components ›› TOgDaysCode Component ›› TOgDaysCode Events ››

property OnChangeCode : TChangeCodeEvent

TChangeCodeEvent = procedure(Sender : TObject; Code : TCode TOgMakeCodes.Code>main) of object;

OnChangeCode defines an event handler that is called when a release code changes.

This event is fired after the release code is changed via a call to Decrease, either directly or automatically (if the AutoDecrease property is True).

Sender is the instance of the release code component. Code is the new release code value.

The release code should be saved in an INI file or the registry.

See also: AutoDecrease TOgDaysCode.AutoDecrease>main, Decrease Decrease>main


TOgDaysCode Methods

Components ›› TOgDaysCode Component ››

CheckCode TOgCodeBase.CheckCode>main

Decrease Decrease>main

GetValue TOgDaysCode.GetValue>main

IsCodeValid TOgCodeBase.IsCodeValid>main


TOgDaysCode.Decrease

Components ›› TOgDaysCode Component ›› TOgDaysCode Methods ››

procedure TOgDaysCode TOgDaysCode_Component>main.Decrease;

Decrease reduces the day count value stored in the release code.

Performing this action requires several vital pieces of information, which are normally obtained by triggering several event handlers that you define. The normal sequence of events performed by Decrease is:

1. Trigger the OnGetKey TOgCodeBase.OnGetKey>main event to get the key used to encode and decode the release code. The key should always be embedded in the application as a constant.

2. Trigger the OnGetCode TOgCodeBase.OnGetCode>main event to get the release code. The release code is normally stored in the registry or an INI file.

3. Trigger the OnGetModifier TOgCodeBase.OnGetModifier>main event to get the key modifier. The modifier can be stored as a constant in the application, stored in the registry or INI file, or generated when it is needed.

4. Apply the modifier to the key.

5. Test the code to see if it is valid.

6. Decrease the day count by one if it has not already been decreased today.

7. Trigger the OnChangeCode event to store the changed release code.

See also: OnChangeCode TOgDaysCode.OnChangeCode>main, OnGetCode TOgCodeBase.OnGetCode>main, OnGetKey TOgCodeBase.OnGetKey>main, OnGetModifier TOgCodeBase.OnGetModifier>main


TOgDaysCode.GetValue

Components ›› TOgDaysCode Component ›› TOgDaysCode Methods ››

function TOgDaysCode TOgDaysCode_Component>main.GetValue : LongInt;

GetValue returns the day count embedded in the release code.

The value returned is the number of days remaining.


TOgDaysCode Properties

Components ›› TOgDaysCode Component ››

AutoCheck TOgCodeBase.AutoCheck>main

AutoDecrease TOgDaysCode.AutoDecrease>main

Code TOgCodeBase.Code>main

StoreCode TOgCodeBase.StoreCode>main


TOgDaysCode.AutoDecrease

Components ›› TOgDaysCode Component ›› TOgDaysCode Properties ››

property TOgDaysCode TOgDateCode_Component>main.AutoDecrease : Boolean

Default: True

AutoDecrease determines whether the day count value is automatically decreased each day the application is run.

If AutoDecrease is True, the day count embedded in the release code is automatically decreased by one each day the application is run. This is accomplished by calling the Decrease method. If AutoDecrease is False, you must call the Decrease method manually whenever necessary.

See also: Decrease Decrease>main


TOgMakeCodes Component

Components ››

See also: properties TOgMakeCodes_Properties>prop, methods TOgMakeCodes_Methods>meth

TOgMakeCodes is a non-visual component that displays a dialog when its Execute method is called. The dialog allows you to create several types of release codes. Each release code consists of 8 bytes and is viewed and entered as 16 hexadecimal digits.


TOgMakeCodes Methods

Components ›› TOgMakeCodes Component ››

Execute TOgMakeCodes.Execute>main


TOgMakeCodes.Execute

Components ›› TOgMakeCodes Component ›› TOgMakeCodes Methods ››

function TOgMakeCodes TOgMakeCodes_Component>main.Execute : Boolean;

Execute displays the Code Generation dialog.

Use this method to display the Code Generation dialog so that a release code can be generated.

If Execute returns True, the Code and CodeType properties contain valid values. Otherwise, the contents of these properties is unknown.

See also: Code TOgMakeCodes.Code>main, CodeType TOgMakeCodes.CodeType>main


TOgMakeCodes Properties

Components ›› TOgMakeCodes Component ››

Code TOgMakeCodes.Code>main

CodeType TOgMakeCodes.CodeType>main

Key TOgMakeCodes.Key>main

KeyFileName TOgMakeCodes.KeyFileName>main

KeyType TOgMakeCodes.KeyType>main

ShowHints TOgMakeCodes.ShowHints>main


TOgMakeCodes.Code

Components ›› TOgMakeCodes Component ›› TOgMakeCodes Properties ››

property TOgMakeCodes TOgMakeCodes_Component>main.Code : TCode

TCode = packed record
CheckValue : Word; {magic value}
Expiration : Word; {expiration date or 0, if none}
case Byte of
0 : (FirstDate : Word; {for date code}
EndDate : Word);
1 : (Days : Word; {for days code}
LastAccess : Word);
2 : (RegString : LongInt); {for reg code}
3 : (SerialNumber : LongInt); {for serial number code}
4 : (UsageCount : Word; {for usage count code}
(LastChange :Word);
5 : (Value : LongInt); {for special codes}
6 : (NetIndex : LongInt); {for net codes}
end;

Code is the generated release code.

After a successful call to Execute, Code contains the generated release code.

Code can represent any one of several release code types. Use the CodeType property to determine which code type was generated.

See also: CodeType TOgMakeCodes.CodeType>main, Execute TOgMakeCodes.Execute>main


TOgMakeCodes.CodeType

Components ›› TOgMakeCodes Component ›› TOgMakeCodes Properties ››

property TOgMakeCodes TOgMakeCodes_Component>main.CodeType : TCodeType

TCodeType = (ctDate, ctDays, ctRegistration, ctSerialNumber, ctUsage, ctNetwork, ctSpecial, ctUnknown);

Default: ctDate

CodeType is the type of release code.

If you assign a value to CodeType prior to calling Execute, the corresponding notebook page is displayed in the Code Generation dialog. After a successful call to Execute, CodeType contains the type of code that was generated. The ctUnknown code type is only used internally.

See also: Execute TOgMakeCodes.Execute>main


TOgMakeCodes.Key

Components ›› TOgMakeCodes Component ›› TOgMakeCodes Properties ››

property TOgMakeCodes TOgMakeCodes_Component>main.Key : TKey

TKey = array [0..15] of Byte;

Key is used to encode and decode the release code.

The key used to encode release codes should be protected from unauthorized use because a release code that was encoded without a modifier can easily be decoded using the key.

The key should be embedded into the application rather than stored in a file or resource.

If no value is assigned to this property, the Key Maintenance dialog is displayed so that a key can be selected or created.

See also: Code TOgMakeCodes.Code>main


TOgMakeCodes.KeyFileName

Components ›› TOgMakeCodes Component ›› TOgMakeCodes Properties ››

property TOgMakeCodes TOgMakeCodes_Component>main.KeyFileName : string

KeyFileName is the name of the INI file used to store application names and their associated keys.

If a valid file name is assigned to this property, its contents are displayed when the Key Maintenance dialog is displayed.


TOgMakeCodes.KeyType

Components ›› TOgMakeCodes Component ›› TOgMakeCodes Properties ››

property TOgMakeCodes TOgMakeCodes_Component>main.KeyType : TKeyType

TKeyType = (ktRandom, ktMessageDigest, ktMessageDigestCS);

Default: ktMessageDigest

KeyType determines the type of key to generate.

The valid key types are:

ktRandom | The key is generated using Delphi’s random number generator.
ktMessageDigest (Standard Text) | The key is generated by using the supplied text. Text case is ignored.
KtMessageDigestCS (Case-Sensitive Text) | The key is generated by using the supplied text. Text case is considered.

If a value is assigned to this property, it is used to determine the type of key to generate when the Key Maintenance dialog is displayed.


TOgMakeCodes.ShowHints

Components ›› TOgMakeCodes Component ›› TOgMakeCodes Properties ››

property TOgMakeCodes TOgMakeCodes_Component>main.ShowHints : Boolean

Default: False

ShowHints determines whether hints are shown for the TOgMakeCodes dialogs.


TOgMakeKeys Component

Components ››

See also: properties TOgMakeKeys_Properties>prop, methods TOgMakeKeys_Methods>meth

TOgMakeKeys is a non-visual component that displays a dialog when its Execute method is called. The dialog allows you to create and maintain keys. Keys are used to encode and decode the release codes that the other OnGuard components use.


TOgMakeKeys Methods

Components ›› TOgMakeKeys Component ››

ApplyModifierToKey TOgMakeKeys.ApplyModifierToKey>main

Execute TOgMakeKeys.Execute>main

GenerateDateModifier TOgMakeKeys.GenerateDateModifier>main

GenerateKey TOgMakeKeys.GenerateKey>main

GenerateMachineModifier TOgMakeKeys.GenerateMachineModifier>main

GenerateRandomKey TOgMakeKeys.GenerateRandomKey>main

GenerateStringModifier TOgMakeKeys.GenerateStringModifier>main

GenerateUniqueModifier TOgMakeKeys.GenerateUniqueModifier>main


TOgMakeKeys.ApplyModifierToKey

Components ›› TOgMakeKeys Component ›› TOgMakeKeys Methods ››

procedure TOgMakeKeys TOgMakeKeys_Component>main.ApplyModifierToKey (Modifier : LongInt; var Key; KeySize : Cardinal);

ApplyModifierToKey alters the specified key.

If Modifier is not zero, this routine alters (signs) the key specified by Key. KeySize is the size, in bytes, of Key .

This routine is used automatically by the components that generate a release code when a non-zero value is specified for the Modifier property.

See also: GenerateDateModifier TOgMakeKeys.GenerateDateModifier>main, GenerateMachineModifier TOgMakeKeys.GenerateMachineModifier>main, GenerateStringModifier TOgMakeKeys.GenerateStringModifier>main, GenerateUniqueModifier TOgMakeKeys.GenerateUniqueModifier>main, Key TOgMakeKeys.Key>main


TOgMakeKeys.Execute

Components ›› TOgMakeKeys Component ›› TOgMakeKeys Methods ››

function TOgMakeKeys TOgMakeKeys_Component>main.Execute: Boolean;

Execute displays the Key Maintenance dialog.

Use this method to display the Key Maintenance dialog so that a key can be generated. The dialog is described in the "Creating and Maintaining Keys" section of the manual.

If Execute returns True, the Key, KeyFileName, and KeyType properties contain valid values. Otherwise, the contents of these properties is unknown.

See also: Key TOgMakeKeys.Key>main, KeyFileName TOgMakeKeys.KeyFileName>main, KeyType TOgMakeKeys.KeyType>main


TOgMakeKeys.GenerateDateModifier

Components ›› TOgMakeKeys Component ›› TOgMakeKeys Methods ››

function TOgMakeKeys TOgMakeKeys_Component>main.GenerateDateModifier: LongInt;

GenerateDateModifier creates a key modifier based on the current date.

This routine is also available as a function (GenerateDateModifierPrim) for use in applications that need to generate modifiers dynamically.

See also: ApplyModifierToKey TOgMakeKeys.ApplyModifierToKey>main, GenerateMachineModifier TOgMakeKeys.GenerateMachineModifier>main, GenerateStringModifier TOgMakeKeys.GenerateStringModifier>main, GenerateUniqueModifier TOgMakeKeys.GenerateUniqueModifier>main


TOgMakeKeys.GenerateKey

Components ›› TOgMakeKeys Component ›› TOgMakeKeys Methods ››

procedure TOgMakeKeys TOgMakeKeys_Component>main.GenerateKey (var Key; KeySize : Cardinal; const Str : string);

GenerateKey produces a key based on a supplied text string.

To produce keys that are not case dependent, convert the text to upper case prior to calling GenerateKey.

See also: ApplyModifierToKey TOgMakeKeys.ApplyModifierToKey>main, GenerateRandomKey TOgMakeKeys.GenerateRandomKey>main, Key TOgMakeKeys.Key>main


TOgMakeKeys.GenerateMachineModifier

Components ›› TOgMakeKeys Component ›› TOgMakeKeys Methods ››

function TOgMakeKeys TOgMakeKeys_Component>main.GenerateMachineModifier: LongInt;

GenerateMachineModifier creates a key modifier based on the hardware information for the current machine.

GenerateMachineModifier uses hard disk volume sizes, volume serial numbers, registration name/company as reported by Windows, and the network card ID (if available) to produce a modifier specific to a single machine.

Use this modifier to sign the key used to encode and decode release codes if you want the release code to restrict usage to a single machine.

M Caution: If hardware is changed on the machine, the modifier changes, rendering the release code, and consequently the application, unusable.

This routine is also available as a function (GenerateMachineModifierPrim) for use in applications that need to generate modifiers dynamically.

See also: ApplyModifierToKey TOgMakeKeys.ApplyModifierToKey>main, GenerateDateModifier TOgMakeKeys.GenerateDateModifier>main, GenerateStringModifier TOgMakeKeys.GenerateStringModifier>main, GenerateUniqueModifier TOgMakeKeys.GenerateUniqueModifier>main


TOgMakeKeys.GenerateRandomKey

Components ›› TOgMakeKeys Component ›› TOgMakeKeys Methods ››

procedure TOgMakeKeys TOgMakeKeys_Component>main.GenerateRandomKey(var Key; KeySize : Cardinal);

GenerateRandomKey produces a key based on Delphi’s internal random number generator.

See also: ApplyModifierToKey TOgMakeKeys.ApplyModifierToKey>main, GenerateKey TOgMakeKeys.GenerateKey>main, Key TOgMakeKeys.Key>main


TOgMakeKeys.GenerateStringModifier

Components ›› TOgMakeKeys Component ›› TOgMakeKeys Methods ››

function TOgMakeKeys TOgMakeKeys_Component>main.GenerateStringModifier (const S : string) : LongInt;

GenerateStringModifier creates a key modifier based on the supplied string.

This routine is also available as a function (GenerateStringModifierPrim) for use in applications that need to generate modifiers dynamically.

See also: ApplyModifierToKey TOgMakeKeys.ApplyModifierToKey>main, GenerateDateModifier TOgMakeKeys.GenerateDateModifier>main, GenerateMachineModifier TOgMakeKeys.GenerateMachineModifier>main, GenerateUniqueModifier TOgMakeKeys.GenerateUniqueModifier>main


TOgMakeKeys.GenerateUniqueModifier

Components ›› TOgMakeKeys Component ›› TOgMakeKeys Methods ››

function TOgMakeKeys TOgMakeKeys_Component>main.GenerateUniqueModifier: LongInt;

GenerateUniqueModifier creates a unique key modifier.

This routine is also available as a function (GenerateUniqueModifierPrim) for use in applications that need to generate modifiers dynamically.

See also: ApplyModifierToKey TOgMakeKeys.ApplyModifierToKey>main, GenerateDateModifier TOgMakeKeys.GenerateDateModifier>main, GenerateMachineModifier TOgMakeKeys.GenerateMachineModifier>main, GenerateStringModifier TOgMakeKeys.GenerateStringModifier>main


TOgMakeKeys Properties

Components ›› TOgMakeKeys Component ››

Key TOgMakeKeys.Key>main

KeyFileName TOgMakeKeys.KeyFileName>main

KeyType TOgMakeKeys.KeyType>main

ShowHints TOgMakeKeys.ShowHints>main


TOgMakeKeys.Key

Components ›› TOgMakeKeys Component ›› TOgMakeKeys Properties ››

property TOgMakeKeys TOgMakeKeys_Component>main.Key : TKey

TKey = array [0..15] of Byte;

Key is used to encode and decode release codes.

After a successful call to Execute, Key contains the selected key value.

The key used to encode release codes should be protected from unauthorized use because a release code that was encoded without a modifier can easily be decoded using the key.

The key should be embedded into the application rather than stored in a file or resource.

See also: ApplyModifierToKey TOgMakeKeys.ApplyModifierToKey>main, Execute TOgMakeKeys.Execute>main, GenerateKey TOgMakeKeys.GenerateKey>main, GenerateRandomKey TOgMakeKeys.GenerateRandomKey>main


TOgMakeKeys.KeyFileName

Components ›› TOgMakeKeys Component ›› TOgMakeKeys Properties ››

property TOgMakeKeys TOgMakeKeys_Component>main.KeyFileName : string

KeyFileName is the name of the INI file used to store application names and their associated keys.

If a valid file name is assigned to this property, its contents are displayed when the Key Maintenance dialog is displayed.


TOgMakeKeys.KeyType

Components ›› TOgMakeKeys Component ›› TOgMakeKeys Properties ››

property TOgMakeKeys TOgMakeKeys_Component>main.KeyType : TKeyType

TKeyType = (ktRandom, ktMessageDigest, ktMessageDigestCS);

Default: ktMessageDigest

KeyType determines the type of key to generate.

After a successful call to Execute, KeyType contains one of these key types.

ktRandom | The key is generated using Delphi’s random number generator.
ktMessageDigest (Standard Text) | The key is generated by using the supplied text. Text case is ignored.
ktMessageDigestCS (Case-Sensitive Text) | The key is generated by using the supplied text. Text case is considered.

If a value is assigned to this property, it is used to determine the type of key to generate when the Key Maintenance dialog is displayed.

See also: Execute TOgMakeKeys.Execute>main


TOgMakeKeys.ShowHints

Components ›› TOgMakeKeys Component ›› TOgMakeKeys Properties ››

property TOgMakeKeys TOgMakeKeys_Component>main.ShowHints : Boolean

Default: False

ShowHints determines whether hints are shown for the TOgMakeKeys dialogs.


TOgNetCode Component

Components ››

See also: properties TOgNetCode_Properties>prop, events TOgNetCode_Events>event, methods TOgNetCode_Methods>meth

TOgNetCode implements a Network Metering release code. This release code limits the number of concurrent instances of an application that are allowed to run on a network. It does this through the use of a network release code and a Network Access File. The use of a network release code is no different than other release codes, but there are additional maintenance issues related to the network file that your application must handle.


TOgNetCode Events

Components ›› TOgNetCode Component ››

OnChecked TOgCodeBase.OnChecked>main

OnGetKey TOgCodeBase.OnGetKey>main

OnGetCode TOgCodeBase.OnGetCode>main

OnGetModifier TOgCodeBase.OnGetModifier>main


TOgNetCode Methods

Components ›› TOgNetCode Component ››

CheckCode TOgCodeBase.CheckCode>main

IsCodeValid TOgCodeBase.IsCodeValid>main

IsRemoteDrive TOgNetCode.IsRemoteDrive>main

ResetAccessFile TOgNetCode.ResetAccessFile>main


TOgNetCode.IsRemoteDrive

Components ›› TOgNetCode Component ›› TOgNetCode Methods ››

function TOgNetCode TOgNetCode_Component>main.IsRemoteDrive(const ExePath : string) : Boolean;

IsRemoteDrive determines whether ExePath resides on a remote disk drive.

You can use IsRemoteDrive to determine if your application is being run from a remote disk drive. Only the drive information passed in ExePath is used.


TOgNetCode.ResetAccessFile

Components ›› TOgNetCode Component ›› TOgNetCode Methods ››

function TOgNetCode TOgNetCode_Component>main.ResetAccessFile : Boolean;

ResetAccessFile resets the invalid slots in the Network Access File.

If the operation is successful, the return value is True. If the file could not be opened for write access, the return value is False.

Calling ResetAccessFile does not effect active users. Since their access slots are in use, they are assumed to be valid and are not reset.


TOgNetCode Properties

Components ›› TOgNetCode Component ››

ActiveUsers TOgNetCode.ActiveUsers>main

AutoCheck TOgCodeBase.AutoCheck>main

Code TOgCodeBase.Code>main

FileName TOgNetCode.FileName>main

InvalidUsers TOgNetCode.InvalidUsers>main

MaxUsers TOgNetCode.MaxUsers>main

Modifier TOgCodeBase.Modifier>main

StoreCode TOgCodeBase.StoreCode>main

StoreModifier TOgCodeBase.StoreModifier>main


TOgNetCode.ActiveUsers

Components ›› TOgNetCode Component ›› TOgNetCode Properties ››

property TOgNetCode TOgNetCode_Component>main.ActiveUsers : LongInt

ActiveUsers is the current number of users running the application.


TOgNetCode.FileName

Components ›› TOgNetCode Component ›› TOgNetCode Properties ››

property TOgNetCode TOgNetCode_Component>main.FileName : string

FileName is the name of the Network Access File.

The Network Access File is used to determine if another instance of the application is authorized. If the file specified in FileName does not exist, it is created and initialized during the call to CheckCode.


TOgNetCode.InvalidUsers

Components ›› TOgNetCode Component ›› TOgNetCode Properties ››

property TOgNetCode TOgNetCode_Component>main.InvalidUsers : LongInt

InvalidUsers is the number of invalid user access slots in the Network Access File.

Invalid slots are created when the user does not exit the application normally. Use ResetAccessFile to fix these invalid slots.

See also: ResetAccessFile TOgNetCode.ResetAccessFile>main


TOgNetCode.MaxUsers

Components ›› TOgNetCode Component ›› TOgNetCode Properties ››

property TOgNetCode TOgNetCode_Component>main.MaxUsers : LongInt

MaxUsers is the maximum number of concurrent users of the application.


TOgProtectExe Component

Components ››

See also: properties TOgProtectExe_Properties>prop, events TOgProtectExe_Events>event, methods TOgProtectExe_Methods>meth

The TOgProtectExe component allows you to detect changes to your EXE file. The size of the EXE file and a 32-bit CRC (Cyclical Redundancy Check) value are recorded in the EXE file and checked each time the application is run.


TOgProtectExe Events

Components ›› TOgProtectExe Component ››

OnChecked TOgProtectExe.OnChecked>main


TOgProtectExe.OnChecked

Components ›› TOgProtectExe Component ›› TOgProtectExe Events ››

property TOgProtectExe TOgProtectExe_Component>main.OnChecked : TCheckedExeEvent

TCheckedExeEvent = procedure(Sender : TObject; Status : TExeStatus) of object;

OnChecked defines an event handler that is called after the executable is checked.

Sender is the instance of the release code component. Status is the value returned by a call to CheckExe.

See also: CheckExe TOgProtectExe.CheckExe>main


TOgProtectExe Methods

Components ›› TOgProtectExe Component ››

CheckExe TOgProtectExe.CheckExe>main

StampExe TOgProtectExe.StampExe>main

UnStampExe TOgProtectExe.UnStampExe>main


TOgProtectExe.CheckExe

Components ›› TOgProtectExe Component ›› TOgProtectExe Methods ››

function TOgProtectExe TOgProtectExe_Component>main.CheckExe(Report : Boolean) : TExeStatus;

TExeStatus = (exeSuccess, exeSizeError, exeIntegrityError, exeNotStamped);

CheckExe tests to see if the executable file was altered.

If Report is True, the result of the test is reported by triggering the OnChecked event. If Report is False, you must check the function result.

The result of calling CheckExe is one of the following values:

exeSuccess | The executable file has not changed.
exeSizeError | The size of the executable file changed.
exeIntegrityError | One or more bytes in the executable changed.
exeNotStamped | The executable is not stamped with the CRC and size information.

See also: OnChecked TOgProtectExe.OnChecked>main


TOgProtectExe.StampExe

Components ›› TOgProtectExe Component ›› TOgProtectExe Methods ››

function TOgProtectExe TOgProtectExe_Component>main.StampExe (const FileName : string ; EraseMarker : Boolean) : Boolean;

StampExe marks the executable program with its size and a CRC value.

StampExe searches for a special marker that is used to mark the record where the size and CRC value are stored, calculates the executable’s size and CRC, and writes that information back to the record. If EraseMarker is True, the special marker used to locate the record is erased.

This method is not used by the TOgProtectExe component. It is provided so that you can use it to stamp the application you want to protect. You can write a simple application that uses StampExe to stamp the application you want to protect. Or you can use the STAMPEXE example project (which uses the StampExe method) to stamp the application you want to protect.

See also: UnStampExe TOgProtectExe.UnStampExe>main


TOgProtectExe.UnStampExe

Components ›› TOgProtectExe Component ›› TOgProtectExe Methods ››

function TOgProtectExe TOgProtectExe_Component>main.UnStampExe (const FileName : string) : Boolean;

UnStampExe reverses the effect of a call to StampExe.

UnStampExe can only be used if the special marker used to locate the CRC record was not erased by StampExe.

This method is not used by the TOgProtectExe component. It is provided so that you can use it unstamp an application.

See also: StampExe TOgProtectExe.StampExe>main


TOgProtectExe Properties

Components ›› TOgProtectExe Component ››

AutoCheck TOgProtectExe.AutoCheck>main

CheckSize TOgProtectExe.CheckSize>main


TOgProtectExe.AutoCheck

Components ›› TOgProtectExe Component ›› TOgProtectExe Properties ››

property TOgProtectExe TOgProtectExe_Component>main.AutoCheck : Boolean

Default: False

AutoCheck determines whether CheckExe is called automatically.

If AutoCheck is True, CheckExe is called after the form containing this component is loaded. If AutoCheck is False, you are responsible for calling CheckExe to determine the status of the executable file.

See also: CheckExe TOgProtectExe.CheckExe>main


TOgProtectExe.CheckSize

Components ›› TOgProtectExe Component ›› TOgProtectExe Properties ››

property TOgProtectExe TOgProtectExe_Component>main.CheckSize : Boolean

Default: True

CheckSize determines whether the size of the executable is tested.

If CheckSize is True, the size and the CRC of the executable file are tested. If CheckSize is False, only the CRC of the executable file is tested.


TOgRegistrationCode Component

Components ››

See also: properties TOgRegistrationCode_Properties>prop, events TOgRegistrationCode_Events>event, methods TOgRegistrationCode_Methods>meth

TOgRegistrationCode implements a Simple Registration release code. This release code ties the user’s name, company name, or some other textual data to the registration code.


TOgRegistrationCode Events

Components ›› TOgRegistrationCode Component ››

OnChecked TOgCodeBase.OnChecked>main

OnGetKey TOgCodeBase.OnGetKey>main

OnGetCode TOgCodeBase.OnGetCode>main

OnGetModifier TOgCodeBase.OnGetModifier>main

OnGetRegString TOgRegistrationCode.OnGetRegString>main


TOgRegistrationCode.OnGetRegString

Components ›› TOgRegistrationCode Component ›› TOgRegistrationCode Events ››

property TOgRegistrationCode TOgRegistrationCode_Component>main.OnGetRegString : TGetRegStringEvent

TGetRegStringEvent = procedure(Sender : TObject; var Value : string) of object;

OnGetRegString defines an event handler that is called to get the registration string.

Sender is the instance of the release code component. Value is the registration string used to create the release code.


TOgRegistrationCode Methods

Components ›› TOgRegistrationCode Component ››

CheckCode TOgCodeBase.CheckCode>main

IsCodeValid TOgCodeBase.IsCodeValid>main


TOgRegistrationCode Properties

Components ›› TOgRegistrationCode Component ››

AutoCheck TOgCodeBase.AutoCheck>main

Code TOgCodeBase.Code>main

Modifier TOgCodeBase.Modifier>main

RegString TOgRegistrationCode.RegString>main

StoreCode TOgCodeBase.StoreCode>main

StoreModifier TOgCodeBase.StoreModifier>main

StoreRegString TOgRegistrationCode.StoreRegString>main


TOgRegistrationCode.RegString

Components ›› TOgRegistrationCode Component ›› TOgRegistrationCode Properties ››

property TOgRegistrationCode TOgRegistrationCode_Component>main.RegString : string

RegString is the registration string used to create the release code.

See also: OnGetRegString TOgRegistrationCode.OnGetRegString>main


TOgRegistrationCode.StoreRegString

Components ›› TOgRegistrationCode Component ›› TOgRegistrationCode Properties ››

property TOgRegistrationCode TOgRegistrationCode_Component>main.StoreRegString : Boolean

Default: True

StoreRegString determines whether the registration string value is stored as a resource at design time.

If StoreRegString is True, the value of RegString is stored in the resource file along with the form. If StoreRegString is False, RegString is not stored and you must supply an OnGetRegString event handler so that the registration string can be retrieved when required.

See also: OnGetRegString TOgRegistrationCode.OnGetRegString>main, RegString TOgRegistrationCode.RegString>main


TOgSerialNumberCode Component

Components ››

See also: properties TOgSerialNumberCode_Properties>prop, events TOgSerialNumberCode_Events>event, methods TOgSerialNumberCode_Methods>meth

TOgSerialNumberCode implements a Serial Number Registration release code. This release code ties a serial number to the release code. This release code is very similar to the Simple Registration release code. The only difference is in the data that is used as part of the code generation process. The Serial Number Registration release code uses a number instead of a text string.


TOgSerialNumberCode Events

Components ›› TOgSerialNumberCode Component ››

OnChecked TOgCodeBase.OnChecked>main

OnGetKey TOgCodeBase.OnGetKey>main

OnGetCode TOgCodeBase.OnGetCode>main

OnGetModifier TOgCodeBase.OnGetModifier>main


TOgSerialNumberCode Methods

Components ›› TOgSerialNumberCode Component ››

CheckCode TOgCodeBase.CheckCode>main

GetValue TOgSerialNumberCode.GetValue>main

IsCodeValid TOgCodeBase.IsCodeValid>main


TOgSerialNumberCode.GetValue

Components ›› TOgSerialNumberCode Component ›› TOgSerialNumberCode Methods ››

function TOgSerialNumberCode TOgSerialNumberCode_Component>main.GetValue : LongInt;

GetValue returns the serial number embedded in the release code.

The value returned is the serial number that was used when the release code was created.


TOgSerialNumberCode Properties

Components ›› TOgSerialNumberCode Component ››

AutoCheck TOgCodeBase.AutoCheck>main

Code TOgCodeBase.Code>main

Modifier TOgCodeBase.Modifier>main

StoreCode TOgCodeBase.StoreCode>main

StoreModifier TOgCodeBase.StoreModifier>main


TOgSpecialCode Component

Components ››

See also: properties TOgSpecialCode_Properties>prop, events TOgSpecialCode_Events>event, methods TOgSpecialCode_Methods>meth

TOgSpecialCode implements a Special Registration release code. This release code is based on a special value (a long integer) that can be used to indicate anything you like.


TOgSpecialCode Events

Components ›› TOgSpecialCode Component ››

OnChecked TOgCodeBase.OnChecked>main

OnGetKey TOgCodeBase.OnGetKey>main

OnGetCode TOgCodeBase.OnGetCode>main

OnGetModifier TOgCodeBase.OnGetModifier>main


TOgSpecialCode Methods

Components ›› TOgSpecialCode Component ››

CheckCode TOgCodeBase.CheckCode>main

GetValue TOgSpecialCode.GetValue>main

IsCodeValid TOgCodeBase.IsCodeValid>main


TOgSpecialCode.GetValue

Components ›› TOgSpecialCode Component ›› TOgSpecialCode Methods ››

function TOgSpecialCode TOgSpecialCode_Component>main.GetValue : LongInt;

GetValue returns the special information embedded in the release code.

The returned value is a LongInt. The interpretation of the returned value is determined entirely by you.


TOgSpecialCode Properties

Components ›› TOgSpecialCode Component ››

AutoCheck TOgCodeBase.AutoCheck>main

Code TOgCodeBase.Code>main

Modifier TOgCodeBase.Modifier>main

StoreCode TOgCodeBase.StoreCode>main

StoreModifier TOgCodeBase.StoreModifier>main


TOgUsageCode Component

Components ››

See also: properties TOgUsageCode_Properties>prop, events TOgUsageCode_Events>event, methods TOgUsageCode_Methods>meth

TOgUsageCode implements a Usage Count release code. This release code limits the number of times an application can be executed.


TOgUsageCode Events

Components ›› TOgUsageCode Component ››

OnChangeCode TOgUsageCode.OnChangeCode>main

OnChecked TOgCodeBase.OnChecked>main

OnGetKey TOgCodeBase.OnGetKey>main

OnGetCode TOgCodeBase.OnGetCode>main

OnGetModifier TOgCodeBase.OnGetModifier>main


TOgUsageCode.OnChangeCode

Components ›› TOgUsageCode Component ›› TOgUsageCode Events ››

property TOgUsageCode TOgUsageCode_Component>main.OnChangeCode : TChangeCodeEvent

TChangeCodeEvent = procedure(Sender : TObject; Code : TCode TOgMakeCodes.Code>main) of object;

OnChangeCode defines an event handler that is called when a release code changes.

This event is fired after the release code is changed via a call to Decrease, either directly or automatically (if the AutoDecrease property is True).

Sender is the instance of the release code component. Code is the new release code value.

The release code should be saved in the INI file or the registry.

See also: AutoDecrease TOgUsageCode.AutoDecrease>main, Decrease TOgUsageCode.Decrease>main


TOgUsageCode Methods

Components ›› TOgUsageCode Component ››

CheckCode TOgCodeBase.CheckCode>main

Decrease TOgUsageCode.Decrease>main

GetValue TOgUsageCode.GetValue>main

IsCodeValid TOgCodeBase.IsCodeValid>main


TOgUsageCode.Decrease

Components ›› TOgUsageCode Component ›› TOgUsageCode Methods ››

procedure TOgUsageCode TOgUsageCode_Component>main.Decrease;

Decrease reduces the usage count value stored in the release code.

Performing this action requires several vital pieces of information, which are normally obtained by triggering several event handlers that you define. The normal sequence of events performed by Decrease is:

1. Trigger the OnGetKey TOgCodeBase.OnGetKey>main event to get the key used to encode and decode the release code. The key should always be embedded in the application as a constant.

2. Trigger the OnGetCode TOgCodeBase.OnGetCode>main event to get the release code. The code is normally stored in the registry or an INI file.

3. Trigger the OnGetModifier TOgCodeBase.OnGetModifier>main event to get the key modifier. The key modifier can be stored as a constant in the application, stored in the registry or INI file, or generated when it is needed.

4. Apply the modifier to the key.

5. Test the release code to see if it is valid.

6. Decrease the usage count by one.

7. Trigger the OnChangeCode TOgUsageCode.OnChangeCode>main event to store the changed release code.

See also: OnChangeCode TOgUsageCode.OnChangeCode>main, OnGetCode, TOgCodeBase.OnGetCode>main OnGetKey, TOgCodeBase.OnGetKey>main OnGetModifier TOgCodeBase.OnGetModifier>main,


TOgUsageCode.GetValue

Components ›› TOgUsageCode Component ›› TOgUsageCode Methods ››

function TOgUsageCode TOgUsageCode_Component>main.GetValue : LongInt;

GetValue returns the usage count embedded in the release code.

The value returned is the number of runs remaining.


TOgUsageCode Properties

Components ›› TOgUsageCode Component ››

AutoCheck TOgCodeBase.AutoCheck>main

AutoDecrease TOgUsageCode.AutoDecrease>main

Modifier TOgCodeBase.Modifier>main

StoreModifier TOgCodeBase.StoreModifier>main


TOgUsageCode.AutoDecrease

Components ›› TOgUsageCode Component ›› TOgUsageCode Properties ››

property TOgUsageCode TOgUsageCode_Component>main.AutoDecrease : Boolean

Default: True

AutoDecrease determines whether the usage count value is automatically decreased each time the application is run.

If AutoDecrease is True, the usage count value embedded in the release code is automatically decreased by one each time the application is run. When the usage count is reduced to zero, the release code is expired. If AutoDecrease is False, you must call the Decrease method manually whenever necessary.

See also: Decrease TOgUsageCode.Decrease>main


Low-Level Routines / API Reference

ApplyModifierToKeyPrim ApplyModifierToKeyPrim

BufferToHex BufferToHex

BufferToHexBytes BufferToHexBytes

CheckNetAccessFile CheckNetAccessFile

CreateNetAccessFile CreateNetAccessFile

CreateNetAccessFileEx CreateNetAccessFileEx

DecDaysCode DecDaysCode

DecodeNAFCountCode DecodeNAFCountCode

DecUsageCode DecUsageCode

EncodeNAFCountCode EncodeNAFCountCode

ExpandDate ExpandDate

GenerateDateModifierPrim GenerateDateModifierPrim

GenerateMachineModifierPrim GenerateMachineModifierPrim

GenerateMD5KeyPrim GenerateMD5KeyPrim

GenerateRandomKeyPrim GenerateRandomKeyPrim

GenerateStringModifierPrim GenerateStringModifierPrim

GenerateTMDKeyPrim GenerateTMDKeyPrim

GenerateUniqueModifierPrim GenerateUniqueModifierPrim

GetCodeType GetCodeType

GetDateCodeValue GetDateCodeValue

GetDaysCodeValue GetDaysCodeValue

GetExpirationDate GetExpirationDate

GetNetAccessFileInfo GetNetAccessFileInfo

GetSerialNumberCodeValue GetSerialNumberCodeValue

GetSpecialCodeValue GetSpecialCodeValue

GetUsageCodeValue GetUsageCodeValue

HexStringIsZero HexStringIsZero

HexToBuffer HexToBuffer

InitDateCode InitDateCode

InitDaysCode InitDaysCode

InitRegCode InitRegCode

InitSerialNumberCode InitSerialNumberCode

InitSpecialCode InitSpecialCode

InitUsageCode InitUsageCode

IsAppOnNetwork IsAppOnNetwork

IsDateCodeExpired IsDateCodeExpired

IsDateCodeValid IsDateCodeValid

IsDaysCodeExpired IsDaysCodeExpired

IsDaysCodeValid IsDaysCodeValid

IsRegCodeExpired IsRegCodeExpired

IsRegCodeValid IsRegCodeValid

IsSerialNumberCodeExpired IsSerialNumberCodeExpired

IsSerialNumberCodeValid IsSerialNumberCodeValid

IsSpecialCodeExpired IsSpecialCodeExpired

IsSpecialCodeValid IsSpecialCodeValid

IsUsageCodeExpired IsUsageCodeExpired

IsUsageCodeValid IsUsageCodeValid

LockNetAccessFile LockNetAccessFile

ResetNetAccessFile ResetNetAccessFile

ShrinkDate ShrinkDate

StringHashElf StringHashElf

UnlockNetAccessFile UnlockNetAccessFile


ApplyModifierToKeyPrim

Low-Level Routines / API Reference ››

procedure ApplyModifierToKeyPrim (Modifier : LongInt; var Key; KeySize : Cardinal);

ApplyModifierToKeyPrim Xor's the Modifier value with the Key returning the modified key as the Key parameter.

Use this routine to sign a key.

KeySize if the size of the key in bytes

This routine is defined in the OnGuard unit.


BufferToHex

Low-Level Routines / API Reference ››

function BufferToHex (const Buf; BufSize : Cardinal) : string;

BufferToHex converts one or more bytes to hex.

Buf contains one or more bytes and BufSize if the number of bytes in Buf. The hexadecimal version of Buf is returned as the function result.

This routine is defined in the OgUtil unit.


BufferToHexBytes

Low-Level Routines / API Reference ››

function BufferToHexBytes (const Buf; BufSize : Cardinal) : string;

BufferToHexBytes performs the same operation as the BufferToHex function except that the function result is formatted to represent an array of hexadecimal bytes separated by commas.

Example result: "$02, $67, $FF"

This routine is defined in the OgUtil unit.


CheckNetAccessFile

Low-Level Routines / API Reference ››

function CheckNetAccessFile (const NetAccess : TNetAccess) : Boolean;

TNetAccess = packed record
Fh : Integer;
Key : TKey;
CheckValue : Word;
Index : Word;
end;

CheckNetAccessFile verifies that the net access file referenced by NetAccess has at least one slot that is not in use.

If there is at least one open slot in the net access file, CheckNetAccessFile returns true, otherwise false.

This routine is defined in the OgNetWrk unit.


CreateNetAccessFile

Low-Level Routines / API Reference ››

function CreateNetAccessFile (const FileName : string; const Key : TKey; Count : Word) : Boolean;

CreateNetAccessFile creates a net access for Count users file using FileName as the name of the file and Key to encode the file.

If a file with FileName as its name exists it is overwritten without warning.

This routine is defined in the OgNetWrk unit.


CreateNetAccessFileEx

Low-Level Routines / API Reference ››

function CreateNetAccessFileEx (const FileName : string; const Key : TKey; const Code : TCode) : Boolean;

CreateNetAccessFileEx creates a net access file using the access count value from a previously encoded net access Code.

Key must be the same key that was used to create the code or the code is considered invalid.

This routine is defined in the OgNetWrk unit.


DecDaysCode

Low-Level Routines / API Reference ››

procedure DecDaysCode (const Key : TKey; var Code : TCode);

DecDaysCode reduces the internal "days count" value by one and returns the modified code as the Code parameter.

Key must be the same key that was used to create the code or the code is considered invalid.

This routine is defined in the OnGuard unit.


DecUsageCode

Low-Level Routines / API Reference ››

procedure DecUsageCode (const Key : TKey; var Code : TCode);

DecUsageCode reduces the internal "usage count" value by one and returns the modified code as the Code parameter.

Key must be the same key that was used to create the code or the code is considered invalid.

This routine is defined in the OnGuard unit.


DecodeNAFCountCode

Low-Level Routines / API Reference ››

function DecodeNAFCountCode (const Key : TKey; const Code : TCode) : LongInt;

DecodeNAFCountCode uses Key to decode Code and returns the number of authorized users as the function result.

Key must be the same key that was used to create the code or the code is considered invalid. If the code is invalid, 0 is returned.

This routine is defined in the OgNetWrk unit.


EncodeNAFCountCode

Low-Level Routines / API Reference ››

procedure EncodeNAFCountCode (const Key : TKey; Count : Cardinal; var Code : TCode);

EncodeNAFCountCode uses Key to create and encode the usage Count value creating a network code.

The resulting code is returned as the Code parameter.

This routine is defined in the OgNetWrk unit.


ExpandDate

Low-Level Routines / API Reference ››

function ExpandDate (D : Word) : TDateTime;

ExpandDate translates an OnGuard date offset to an actual date.

OnGuard uses a date offset to reduce the amount of space necessary to store a date. OnGuard creates a date offset by subtracting the TDateTime value for 1 January 1996 from the actual date.

Exceptions to the conversion rules are that a value of 0 expands to 1 January 9999 and date offsets larger than 65535 are represented as 0.

This routine is defined in the OnGuard unit.


GenerateDateModifierPrim

Low-Level Routines / API Reference ››

function GenerateDateModifierPrim (D : TDateTime) : LongInt;

GenerateDateModifierPrim produces a key modifier based on the date D.

This routine is defined in the OnGuard unit.

This routine is defined in the OnGuard unit.


GenerateMD5KeyPrim

Low-Level Routines / API Reference ››

procedure GenerateMD5KeyPrim (var Key: TKey; const Str : string);

GenerateMD5KeyPrim produces a Key by applying the MD5 hash to the string passed as Str

The routine is case sensitive.

This routine is defined in the OnGuard unit.


GenerateMachineModifierPrim

Low-Level Routines / API Reference ››

function GenerateMachineModifierPrim: LongInt;

GenerateMachineModifierPrim produces a key modifier based on specific hardware information.

Information about hard disk capacity, network card serial number, and other items specific to a particular computer are used to create this value.

This routine is defined in the OnGuard unit.


GenerateRandomKeyPrim

Low-Level Routines / API Reference ››

procedure GenerateRandomKeyPrim (var Key; KeySize : Cardinal);

GenerateRandomKeyPrim produces a Key using a random numbers.

This routine is defined in the OnGuard unit.


GenerateStringModifierPrim

Low-Level Routines / API Reference ››

function GenerateStringModifierPrim (const S : string) : LongInt;

GenerateStringModifierPrim produces a key modifier by applying a hash algorithm to the string passed in S.

This routine is case sensitive.

This routine is defined in the OnGuard unit.


GenerateTMDKeyPrim

Low-Level Routines / API Reference ››

procedure GenerateTMDKeyPrim (var Key; KeySize : Cardinal; const Str : string);

GenerateTMDKeyPrim produces key by applying a hash algorithm to the string passed in Str.

This routine is defined in the OnGuard unit.


GenerateUniqueModifierPrim

Low-Level Routines / API Reference ››

function GenerateUniqueModifierPrim: LongInt;

GenerateUniqueModifierPrim produces a key modifier using random numbers.

This routine is defined in the OnGuard unit.


GetCodeType

Low-Level Routines / API Reference ››

function GetCodeType (const Key : TKey; const Code : TCode) : TCodeType;

TCodeType = (ctDate, ctDays, ctRegistration, ctSerialNumber, ctUsage, ctNetwork, ctSpecial, ctUnknown);

{bmc bm1.BMP}GetCodeType returns the type of code passed as the Code parameter.

Key must be the same key that was used when the code was created or ctUnknown is returned.

This routine is defined in the OnGuard unit.


GetDateCodeValue

Low-Level Routines / API Reference ››

function GetDateCodeValue (const Key : TKey; const Code : TCode) : TDateTime;

GetDateCodeValue returns the expiration date stored in the Code.

Key must be the same key that was used to create the code or the code is considered invalid. If the code is invalid, 1 January 9999 is returned.

This routine is defined in the OnGuard unit.


GetDaysCodeValue

Low-Level Routines / API Reference ››

function GetDaysCodeValue (const Key : TKey; const Code : TCode) : LongInt;

GetDaysCodeValue returns the expiration date stored in the Code.

Key must be the same key that was used to create the code or the code is considered invalid. If the code is invalid, 0 is returned.

This routine is defined in the OnGuard unit.


GetExpirationDate

Low-Level Routines / API Reference ››

function GetExpirationDate (const Key : TKey; const Code : TCode) : TDateTime;

GetExpirationDate returns the date that the code passed as the Code parameter expires.

If the code has no expiration date or is invalid, 1 January 9999 is returned.Key must be the same key that was used to create the code or the code is considered invalid.

This routine is defined in the OnGuard unit.


GetNetAccessFileInfo

Low-Level Routines / API Reference ››

function GetNetAccessFileInfo (const FileName : string; const Key : TKey; var NetAccessInfo : TNetAccessInfo) : Boolean;

TNetAccessInfo = packed record
Total : Cardinal;
Locked : Cardinal;
Invalid : Cardinal;
end;

GetNetAccessFileInfo obtains information about the specified network access file.

FileName is the name of an existing network access file and Key is the key that was used to create it. The network access file information is returne as the NetAccessInfo parameter and consists of the total number of access slots, the number of locked slots, and the number of invalid access slots. (An access slot becomes invalid when the application using it is terminated in a non-standard way.)

GetNetAccessFileInfo returns false if there was an error, otherwise true.

This routine is defined in the OgNetWrk unit.


GetSerialNumberCodeValue

Low-Level Routines / API Reference ››

function GetSerialNumberCodeValue (const Key : TKey; const Code : TCode) : LongInt;

GetSerialNumberCodeValue returns the serial number that was used to create the Code.

Key must be the same key that was used to create the code or the code is considered invalid. If the code is invalid, 0 is returned.

This routine is defined in the OnGuard unit.


GetSpecialCodeValue

Low-Level Routines / API Reference ››

function GetSpecialCodeValue (const Key : TKey; const Code : TCode) : LongInt;

GetSpecialCodeValue returns the value that was used to create the Code.

Key must be the same key that was used to create the code or the code is considered invalid. If the code is invalid, 0 is returned.

This routine is defined in the OnGuard unit.


GetUsageCodeValue

Low-Level Routines / API Reference ››

function GetUsageCodeValue (const Key : TKey; const Code : TCode) : LongInt;

GetUsageCodeValue returns the current usage count value store in the Code.

Key must be the same key that was used to create the code or the code is considered invalid. If the code is invalid, 0 is returned.

This routine is defined in the OnGuard unit.


HexStringIsZero

Low-Level Routines / API Reference ››

function HexStringIsZero (const Hex : string) : Boolean;

HexStringIsZero returns true if the hexadecimal string passed as Hex consists entirely of 0's, otherwise false.

This routine is defined in the OgUtil unit.


HexToBuffer

Low-Level Routines / API Reference ››

function HexToBuffer (const Hex : string; var Buf; BufSize : Cardinal) : Boolean;

HexToBuffer converts the hexadecimal string in Hex to bytes that are stored in Buf.

Punctuation ($, spaces, commas, parentheses, ...) is ignored.

BufSize is the number of bytes to store in Buf and must be the number of hexadecimal bytes in Hex. If an error occurs, false is returned, otherwise true.

This routine is defined in the OgUtil unit.


InitDateCode

Low-Level Routines / API Reference ››

procedure InitDateCode (const Key : TKey; StartDate, EndDate : TDateTime; var Code : TCode);

InitDateCode creates and initializes a date code using Key, StartDate, and EndDate.

The resulting code is valid for dates between StartDate and EndDate inclusive.

This routine is defined in the OnGuard unit.


InitDaysCode

Low-Level Routines / API Reference ››

procedure InitDaysCode (const Key : TKey; Days : Word; Expires : TDateTime; var Code : TCode);

InitDaysCode creates and initializes a days code using Key, Days, and Expires.

Days is stored as part of the Code.

The resulting code is valid for the number of days of use specified in the Days parameter and until the date stored in Expires is reached.

This routine is defined in the OnGuard unit.


InitRegCode

Low-Level Routines / API Reference ››

procedure InitRegCode (const Key : TKey; const RegStr : string; Expires : TDateTime; var Code : TCode);

InitRegCode creates and initializes a registration code using Key, RegStr, and Expires.

The code stores a hash value that was derived from RegStr. RegStr cannot be extracted from the code.

The resulting code is valid until the date stored in Expires is reached.

This routine is defined in the OnGuard unit.


InitSerialNumberCode

Low-Level Routines / API Reference ››

procedure InitSerialNumberCode (const Key : TKey; Serial : LongInt; Expires : TDateTime; var Code : TCode);

InitSerialNumberCode creates and initializes a serial number code using Key, Serial, and Expires.

Serial is stored as part of the Code.

The resulting code is valid until the date stored in Expires is reached.

This routine is defined in the OnGuard unit.


InitSpecialCode

Low-Level Routines / API Reference ››

procedure InitSpecialCode (const Key : TKey; Value : LongInt; Expires : TDateTime; var Code : TCode);

InitSpecialCode creates and initializes a special code using Key, Value, and Expires.

Value is stored as part of the Code.

The resulting code is valid until the date stored in Expires is reached.

This routine is defined in the OnGuard unit.


InitUsageCode

Low-Level Routines / API Reference ››

procedure InitUsageCode (const Key : TKey; Count : LongInt; Expires : TDateTime; var Code : TCode);

InitUsageCode creates and initializes a usage code using Key, Count, and Expires.

Count is stored as part of the Code.

The resulting code is valid until the internal Count is 0 or the date stored in Expires is reached.

This routine is defined in the OnGuard unit.


IsAppOnNetwork

Low-Level Routines / API Reference ››

function IsAppOnNetwork (const ExePath : string) : Boolean;

IsAppOnNetwork returns true if the drive specified in ExePath is a remote drive, otherwise false.

This routine is defined in the OgNetWrk unit.


IsDateCodeExpired

Low-Level Routines / API Reference ››

function IsDateCodeExpired (const Key : TKey; const Code : TCode) : Boolean;

IsDateCodeExpired returns true if the Code has expired, otherwise false.

Key must be the same key that was used to create the code or the code is considered invalid. If the code is invalid, this function returns true.

This routine is defined in the OnGuard unit.


IsDateCodeValid

Low-Level Routines / API Reference ››

function IsDateCodeValid (const Key : TKey; const Code : TCode) : Boolean;

IsDateCodeValid returns true if Code is a valid date code, otherwise false.

Key must be the same key that was used to create the code or the code is considered invalid.

This routine is defined in the OnGuard unit.


IsDaysCodeExpired

Low-Level Routines / API Reference ››

function IsDaysCodeExpired (const Key : TKey; const Code : TCode) : Boolean;

IsDaysCodeExpired returns true if the Code has expired, otherwise false.

Key must be the same key that was used to create the code or the code is considered invalid. If the code is invalid, this function returns true.

This routine is defined in the OnGuard unit.


IsDaysCodeValid

Low-Level Routines / API Reference ››

function IsDaysCodeValid (const Key : TKey; const Code : TCode) : Boolean;

IsDaysCodeValid returns true if Code is a valid days code, otherwise false.

Key must be the same key that was used to create the code or the code is considered invalid.

This routine is defined in the OnGuard unit.


IsRegCodeExpired

Low-Level Routines / API Reference ››

function IsRegCodeExpired (const Key : TKey; const Code : TCode) : Boolean;

IsRegCodeExpired returns true if the Code has expired, otherwise false.

Key must be the same key that was used to create the code or the code is considered invalid. If the code is invalid, this function returns true.

This routine is defined in the OnGuard unit.


IsRegCodeValid

Low-Level Routines / API Reference ››

function IsRegCodeValid (const Key : TKey; const Code : TCode) : Boolean;

IsRegCodeValid returns true if Code is a valid registration code, otherwise false.

Key must be the same key that was used to create the code or the code is considered invalid.

This routine is defined in the OnGuard unit.


IsSerialNumberCodeExpired

Low-Level Routines / API Reference ››

function IsSerialNumberCodeExpired (const Key : TKey; const Code : TCode) : Boolean;

IsSerialNumberCodeExpired returns true if the Code has expired, otherwise false.

Key must be the same key that was used to create the code or the code is considered invalid. If the code is invalid, this function returns true.

This routine is defined in the OnGuard unit.


IsSerialNumberCodeValid

Low-Level Routines / API Reference ››

function IsSerialNumberCodeValid (const Key : TKey; const Code : TCode) : Boolean;

IsSerialNumberCodeValid returns true if Code is a valid serial number code, otherwise false.

Key must be the same key that was used to create the code or the code is considered invalid.

This routine is defined in the OnGuard unit.


IsSpecialCodeExpired

Low-Level Routines / API Reference ››

function IsSpecialCodeExpired (const Key : TKey; const Code : TCode) : Boolean;

IsSpecialCodeExpired returns true if the Code has expired, otherwise false.

Key must be the same key that was used to create the code or the code is considered invalid. If the code is invalid, this function returns true.

This routine is defined in the OnGuard unit.


IsSpecialCodeValid

Low-Level Routines / API Reference ››

function IsSpecialCodeValid (const Key : TKey; const Code : TCode) : Boolean;

IsSpecialCodeValid returns true if Code is a valid special code, otherwise false.

Key must be the same key that was used to create the code or the code is considered invalid.

This routine is defined in the OnGuard unit.


IsUsageCodeExpired

Low-Level Routines / API Reference ››

function IsUsageCodeExpired (const Key : TKey; const Code: TCode) : Boolean;

IsUsageCodeExpired returns true if the Code has expired, otherwise false.

Key must be the same key that was used to create the code or the code is considered invalid. If the code is invalid, this function returns true.

This routine is defined in the OnGuard unit.


IsUsageCodeValid

Low-Level Routines / API Reference ››

function IsUsageCodeValid (const Key : TKey; const Code : TCode) : Boolean;

IsUsageCodeValid returns true if Code is a valid usage code, otherwise false.

Key must be the same key that was used to create the code or the code is considered invalid.

This routine is defined in the OnGuard unit.


LockNetAccessFile

Low-Level Routines / API Reference ››

function LockNetAccessFile (const FileName : string; const Key : TKey; var NetAccess : TNetAccess) : Boolean;

TNetAccess = packed record
Fh : Integer;
Key : TKey;
CheckValue : Word;
Index : Word;
end;

LockNetAccessFile locks an access slot in the network access file specified by FileName and returns false if an error occurs.

This routine is defined in the OgNetWrk unit.


ResetNetAccessFile

Low-Level Routines / API Reference ››

function ResetNetAccessFile (const FileName : string; const Key : TKey) : Boolean;

ResetNetAccessFile resets invalid access slots by clearing there "in-uses" status.

Access slots that are currently "in-use" are skipped.

This routine is defined in the OgNetWrk unit.


ShrinkDate

Low-Level Routines / API Reference ››

function ShrinkDate (D : TDateTime) : Word;

{bmc bm1.BMP}ShrinkDate translates a date to an OnGuard date offset.

OnGuard uses a date offset to reduce the amount of space necessary to store a date. OnGuard creates a date offset by subtracting the TDateTime value for 1 January 1996 from the actual date.

Exceptions to the conversion rules are that a value of 0 expands to 1 January 9999 and date offsets larger than 65535 are represented as 0.

This routine is defined in the OnGuard unit.


StringHashElf

Low-Level Routines / API Reference ››

function StringHashElf (const Str : string) : LongInt;

{bmc bm1.BMP}StringHashElf produces a hash value based on the text passed in Str.

This routine is defined in the OnGuard unit.


UnlockNetAccessFile

Low-Level Routines / API Reference ››

function UnlockNetAccessFile (var NetAccess : TNetAccess) : Boolean;

TNetAccess = packed record
Fh : Integer;
Key : TKey;
CheckValue : Word;
Index : Word;
end;

UnlockNetAccessFile unlocks an access slot in the network access file specified by FileName and returns false if an error occurs.

This routine is defined in the OgNetWrk unit


OgFirst Unit

The OgFirst unit provides routines that allow you to detect when a second instance of an application is being executed and to force the previous instance of the application to become the active application.

ActivateFirstInstance OgFirst.ActivateFirstInstance

IsFirstInstance OgFirst.IsFirstInstance


OgFirst.ActivateFirstInstance

OgFirst Unit ››

procedure OgFirst OgFirst_Unit.ActivateFirstInstance; {32-bit version}

procedure OgFirst OgFirst_Unit.ActivateFirstInstance(const MainWindowCaption, MainWindowClass : string); {16-bit version}

{bmc bm1.BMP}ActivateFirstInstance locates an application’s main window and then makes it the active window.

ActivateFirstInstance forces the window with the specified caption and class to the top of the z-Order and gives it the focus. This method is normally called after detecting that a second instance of the application was executed and subsequently halted. Calling ActivateFirstInstance gives the appearance that running the application a second time succeeded.

The 32-bit version of ActivateFirstInstance does not take any parameters and automatically locates the application’s main window. The 16-bit version of this routine requires that the class name and caption of the main form be passed as arguments.


OgFirst.IsFirstInstance

OgFirst Unit ››

function OgFirst OgFirst_Unit.IsFirstInstance : Boolean;

IsFirstInstance determines whether this is the first instance of a program.

This method should be called prior to creating any forms so that the application can be terminated if necessary. IsFirstInstance returns True if this is the first instance of the application.

If IsFirstInstance returns False, you can call ActivateFirstInstance to activate the prior instance of the application.