Re: Turbopower OnGuard
From: Andrew Mortlock (amortlock_at_telstra.com)
Date: 05/18/04
- Next message: Marcello Dias: "Debug sql server stored procedures inside Delphi,Is there a way?"
- Previous message: Paul Breneman: "Re: Turbopower OnGuard"
- In reply to: Tim: "Turbopower OnGuard"
- Next in thread: Tim: "Re: Turbopower OnGuard"
- Reply: Tim: "Re: Turbopower OnGuard"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 18 May 2004 23:23:06 +1000
Tim wrote:
> I have used this product for several years now, but now wish to change the
> validation system used. I current use an OgRegistrationCode component with a
> machine modifier which prevents the program being installed on more than one
> machine without contacting me for a further release code. What I now want to
> do is add a date limit as well. However, I don't know if I can do this
> without using an OgDateCode component as well and therefore a second release
> code. Does anyone have any experience of this with OnGuard? Thanks.
>
>
Tim
Below is the code I used for a 30 day trial period followed by
registration. Note you need both the OgDaysCode and OgRegistrationCode.
If the days are expired it ripples on to check the registration code.
procedure TfrmMain.OgDaysCode1ChangeCode(Sender: TObject; Code: TCode);
var
s: string;
firsthalf: string;
secondhalf: string;
strSQL: string;
num: integer;
begin
{$IFDEF TRIAL}
s := BufferToHex(Code, SizeOf(Code));
secondhalf := copy(s, 7, 99);
firsthalf := copy(s, 1, 6);
num := 0;
strSQL := 'Update Configuration set base = ' + quotedstr(secondhalf);
datamodule1.ADODatabase1.ExecSQL(strSQL);
strSQL := 'Update Colours set Screen = ' + quotedstr(firsthalf);
num := 0;
datamodule1.ADODatabase1.ExecSQL(strSQL);
{$ENDIF}
end;
procedure TfrmMain.OgDaysCode1Checked(Sender: TObject;
Status: TCodeStatus);
var
s: string;
Key: TKey;
Code: TCode;
begin
{$IFDEF TRIAL}
case Status of
ogValidCode: begin
OgDaysCode1GetCode(Sender, Code);
OgDaysCode1GetKey(Sender, Key);
s := 'There are ' +
inttostr(GetDaysCodeValue(key, code)) + ' days remaining in your
evaluation period.';
showmessage(s);
end;
ogDayCountUsed: begin
OgDaysCode1.AutoCheck := False;
OgDaysCode1.AutoDecrease := False;
OgRegistrationCode1.CheckCode(True);
end;
ogCodeExpired, ogInvalidCode: ShowMessage('This software has
expired. Please contact Wollombi Software to register');
end;
if (Status <> ogValidCode) and (status <> ogDayCountUsed) then
Application.Terminate;
{$ENDIF}
end;
procedure TfrmMain.OgDaysCode1GetCode(Sender: TObject; var Code: TCode);
var
firsthalf: string;
secondhalf: string;
begin
{$IFDEF TRIAL}
if not datamodule1.ADODatabase1.Connected then
begin
datamodule1.ADODatabase1.DatabaseConnect :=
'File Name=' + ExtractFilePath(ParamStr(0)) + 'Rooms.udl';
datamodule1.ADODatabase1.Open;
end;
with Datamodule1.SecondHalfQuery do
begin
open;
first;
secondhalf := fieldByName('Base').asstring;
Close;
end;
with Datamodule1.FirstHalfQuery do
begin
open;
first;
firsthalf := fieldByName('Screen').asstring;
Close;
end;
HexToBuffer(firsthalf + secondhalf, Code, SizeOf(Code));
{$ENDIF}
end;
procedure TfrmMain.OgDaysCode1GetKey(Sender: TObject; var Key: TKey);
begin
key := CKey;
end;
procedure TfrmMain.OgRegistrationCode1Checked(Sender: TObject;
Status: TCodeStatus);
begin
{$IFDEF TRIAL}
case Status of
ogValidCode: ;
ogInvalidCode: GetRegistrationCode(true);
else Application.Terminate;
end;
{$ENDIF}
end;
procedure TfrmMain.OgRegistrationCode1GetCode(Sender: TObject;
var Code: TCode);
var
reg: TRegistry;
s: string;
begin
reg := Tregistry.Create;
reg.RootKey := HKEY_LOCAL_MACHINE;
if reg.OpenKeyReadOnly('Software\Mine') then
s := reg.ReadString('SN');
reg.CloseKey;
reg.free;
HexToBuffer(S, Code, SizeOf(Code));
end;
procedure TfrmMain.OgRegistrationCode1GetKey(Sender: TObject;
var Key: TKey);
begin
key := CKey;
end;
procedure TfrmMain.OgRegistrationCode1GetModifier(Sender: TObject;
var Value: Integer);
begin
Value := GenerateMachineModifierPrim;
end;
procedure TfrmMain.GetRegistrationCode(kill: boolean);
var
RegCode: TCode;
RegCodeS: String;
ModKey: TKey;
MachineID: String;
Modifier: longint;
reg: TRegistry;
begin
MachineID := '';
Modifier := GenerateMachineModifierPrim;
MachineID := BufferToHex(Modifier, SizeOf(Modifier));
RegCodeS := '';
if InputQuery('Serial no.: '+ MachineID ,'Enter the Release Code',
RegCodeS) then begin
HexToBuffer(RegCodeS, RegCode, SizeOf(RegCode));
ModKey := CKey;
ApplyModifierToKeyPrim(Modifier, ModKey, SizeOf(ModKey));
if IsRegCodeValid(ModKey, RegCode) then begin
reg := Tregistry.Create;
reg.RootKey := HKEY_LOCAL_MACHINE;
if reg.OpenKey('Software\Mine', true) then
reg.WriteString('SN', RegCodeS);
reg.CloseKey;
reg.free;
showmessage('Your registration was recorded. Please record the
number: ' + RegCodeS +
' as you will need it if you have to reinstall this program');
OgDaysCode1.AutoCheck := False;
OgDaysCode1.AutoDecrease := False;
end
else begin
ShowMessage('Invalid Release Code');
if kill then
Application.Terminate;
end;
end
else
begin
ShowMessage('Not Registered');
if kill then
Application.Terminate;
end;
end;
procedure TfrmMain.Register1Click(Sender: TObject);
begin
if OgRegistrationCode1.IsCodeValid then
showmessage('The program is registered')
else
GetRegistrationCode(false);
end;
- Next message: Marcello Dias: "Debug sql server stored procedures inside Delphi,Is there a way?"
- Previous message: Paul Breneman: "Re: Turbopower OnGuard"
- In reply to: Tim: "Turbopower OnGuard"
- Next in thread: Tim: "Re: Turbopower OnGuard"
- Reply: Tim: "Re: Turbopower OnGuard"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|