The InstantProtection function is the instant
function that needs only one parameter, which is the System Image file (.SIF).
The function performs all tasks to protect the application, including detecting
the Key, displaying registration dialog boxes, enforcing the license, etc.
|
|
The following examples demonstrate how to interface the InstantProtection
function to protect a Hello World program.
C# |
using
System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using Ekc; namespace
HelloWorld { public partial class
FormMain
: Form { InstantKeyCheck Kc; public FormMain() { Kc = new InstantKeyCheck(); Kc.KeyID
= 1111111111; // Key ID Kc.ProgramID
= 0; // Program ID Kc.ModuleID
= 0; // Module ID Kc.AppPath
= Application.ExecutablePath; Kc.SystemImageFile
= Application.StartupPath +
@"\Prg0.sif"; // System
Image file InitializeComponent(); } private void
FormMain_Load(object
sender, EventArgs
e) { if
(!Kc.InstantProtection(Handle)) { if(Kc.ErrStr != "") MessageBox.Show(Kc.ErrStr, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error); Close(); return; } } } } |
VB.NET |
Public Class
FormMain Public Kc As InstantKeyCheck Sub New() Kc = New InstantKeyCheck Kc.KeyID = 1111111111
'
Key ID Kc.ProgramID
= 0 ' Program ID Kc.ModuleID
= 0 ' Module ID Kc.AppPath
= Application.ExecutablePath Kc.SystemImageFile
= Application.StartupPath +
"\Prg0.sif"
' System
Image File InitializeComponent() End Sub Private Sub
FormMain_Load(ByVal sender As System.Object,
ByVal
e As System.EventArgs)
Handles MyBase.Load If Not Kc.InstantProtection(Handle) Then If
(Kc.ErrStr <> "") Then MessageBox.Show(Kc.ErrStr, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error) End If Close() End If End Sub End Class |
|
unit
interface uses Windows, Messages, SysUtils,
Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls,
InstantKeyCheck; type TFormMain =
class(TForm) Label1: TLabel; procedure FormCreate(Sender:
TObject); private { Private declarations } public { Public declarations } end; var FormMain: TFormMain; Kc: TInstantKeyCheck; implementation {$R
*.dfm} procedure
TFormMain.FormCreate(Sender: TObject); begin Kc := TInstantKeyCheck.Create(); Kc.KeyID :=
1111111111; // Key ID Kc.ProgramID :=
0; // Program ID Kc.ModuleID :=
0; // Module ID Kc.AppPath := Application.ExeName; Kc.SystemImageFile
:= ExtractFileDir(Application.ExeName)
+ '\Prg0.sif'; // System Image File if not Kc.InstantProtection(Handle)
then begin if Kc.ErrStr
<> '' then MessageDlg(Kc.ErrStr, mtError, [mbCancel], 0); Application.Terminate(); Exit; end; end; end. |
See Also