Click here to Skip to main content
Click here to Skip to main content
Go to top

Shareware registration dialog

, 15 Oct 2002
Rate this:
Please Sign up or sign in to vote.
Dialog that manages shareware application registration and trial period

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":
    ///////////// 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.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Ivan Markovic
Software Developer
Yugoslavia Yugoslavia
Likes C++, templates, patterns, sarmas and loves Luka and Jelena

Comments and Discussions

 
Questionhow to... PinsussIvan Markovic17-Oct-02 13:48 
AnswerRe: how to... PinmemberPiccinano12-May-03 21:11 
GeneralImprovement! PinmembermrAndy16-Oct-02 23:09 
GeneralNumber of days in Registry PinmemberRolando E. Cruz-Marshall16-Oct-02 14:08 
GeneralRe: Number of days in Registry PinmembermrAndy16-Oct-02 22:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web03 | 2.8.140916.1 | Last Updated 16 Oct 2002
Article Copyright 2002 by Ivan Markovic
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid