Introduction
RegDialog is an MFC-based dialog that will help you manage shareware application registrations. When the shareware application is started for the first time; information about the company, application's name, version number, trial period and starting date is created in the registry. Every next time the user starts
the application, RegDialog appears with information about number of days left to use and offers registration
code entering or to continue unregistered. After the trial period is finished user can only enter registration
code and after the shareware application is registered, RegDialog will no more appear. Of course user can register
application during the trial period also. Reinstalling the shareware application will not "help" because the
information about the starting date is left in the registry and "new" application will just continue to count
trial period days. The first time user starts shareware application, RegDialog will not appear - that is because
user should first see and test the application and at that time I think it is not the right time to send him
messages about days left to use or about continuing unregistered. So keep this in mind when you start demo application
or your application with RegDialog - RegDialog will show when you start your
application the 2nd time!
Also, because RegDialog is working with the system registry please see the note below.
How to use it?
- Create or open your existing code.
- In VC++ menu select Project->Add to Project->Components and Controls...
- Browse to RegDialog.ogx (download RegDialog_ogx.zip) and select it.
- In applications main class insert
#include "RegDialog.h"
- In the same class, in
InitInstance()
function insert:
...
SetRegistryKey(_T("MyCompany"));
CRegDialog regDlg;
regDlg.Check();
...
Of course, replace "MyCompany" with something you choose or have as adequate name.
In RegDialog.cpp modify part specified as "App specific data":
int DaysLimit = 30;
long KeyCode = 12345678;
CString Version = "1.1";
where:
DaysLimit
is the number of days application will work unregistered.
KeyCode
is the code that user must enter to register application.
Version
is the string used to avoid newer versions of your software
getting registered if older version was.
All this, you can see in the demo project you can download from this page (RegDialog_demo.zip).
Few things you need to know
The OnAskcode()
function of the CRegDialog
class is the place you should put what
will happen when the user presses the "Register" button. It can be some dialog with
price and hyperlink to registration site,
some register.exe file or "send mail" link. KeyCode
is long type variable. If you need KeyCode
with letters included
modify the code so it writes string types instead of int types
to registry database (see the note below!). Code can be easily modified to calculate user's registration code from letters of his name
instead of using KeyCode
variable
compiled in the application
Note
Because this class is working with the system registry - the important OS database
- be careful if you
change the code. If you don't know exactly what registry functions are doing do not change them! Just use
the class
as it is and it will work. See MSDN for information and help about the registry.