TweetFollow Us on Twitter

Registration Tool
Volume Number:12
Issue Number:12
Column Tag:Shareware Tools

Registration Tools

Tools for Providing Convenient Registration for Shareware

by James George, Los Alamos, NM

Note: Source code files accompanying article are located on MacTech CD-ROM or source code disks.

As we put the finishing touches on our shareware masterpieces, we realized that we had forgotten a vital link - a convenient registration method to encourage users to register and pay for the shareware. We looked around and found none, but MacTech saved the day with a timely article suggesting what was needed (Bill Midesitt - “How to Make $1,000 Per Week Stuffing (Virtual) Envelopes, July 1995). We’ve implemented many of the suggestions for the Metrowerks environment in Pascal or C.

We wanted an easy to include module which a) kept asking the user to register, b) provided an easy way for a user to register, c) allowed the author to create registration numbers, and d) allowed any user to un-register a registered copy to be distributed freely. Thus, Register includes the headers, functions, and resources providing the entire user interface and prints the registration form for mailing or faxing.

Include Register in your Metrowerks project by adding Register.c and Register.rsrc to your project , and inserting two lines in your setup/main module.

Listing 1: Typical Mac Template

Typical Mac Template

Include the Register headers, and check the registration.

#include “Register.h”

main()
{
 (*call usual Macintosh initialization setup routines *)
 
 CheckRegistration();
 
 (* do your event loop *)

}
 

The User Interface

As your application starts, CheckRegistration retrieves the registered name and registration number from the resources, recomputes the registration number from the name and compares it to the registration number from the resource. If these match, CheckRegistration returns and your application continues normally. When they do not match, a information dialog encourages the user to register.

Figure 1. The Information Dialog

Naturally, only the item numbers for the “Register” and “Not Yet” button are important, the rest of the dialog can be modified to promote your application.

If the user chooses “Not Yet”, the application continues normally; but, if “Register” is selected, than the registration dialog allows the information to be entered

Figure 2. The Registration Dialog

The user enters everything but the Registration Number, clicks “Print”, and sends the printed form and fee to YOU! If the user clicks “Cancel” no information is remembered; if the user click “OK”, everything is remembered except the credit card information.

When you receive the registration, you fire up your master copy, enter some special command and the MakeRegistration dialog allows you to enter the information, create a valid registration number from the users name (click on “Make Registration”), and print the information to return to the user.

Figure 3. The Make Registration Dialog

The Details

Now let’s look at the code in detail.

Listing 2: Register.h

Register.h
#define lockedAlert  400  /* application locked alert */
 
#define shareSplashAlert  401 /* the info screen */
 
#define registerDLog 314  /*the register dialog */
#define regPrintItem 3
#define regMkPwdItem 4
#define regFrstPrtItem    5
#define regLastPrtItem    19
#define regFrstOtherSaveItem12
#define regLastOtherSaveItem13
#define regNameItem11
#define regNumberItem19
 
#define regDataResType    ‘ABCD’
 
#define regNumSeedValue   1234/* seed value for test */
 
typedef long *longptr, **longhan;

 /* Prototypes */

void PrintRegForm(DialogPtr theDialog);
long ComputeRegistration(Str255 name);
void MakeRegistration(void);
void UnRegister(void);
void Register(void);
void CheckRegistration(void);

lockedAlert is the id for the alert which informs the user that the application is locked and thus no registration information can be remembered. The “OK” button must remain item 1.

shareSplashAlert is the id for the information alert which describes the features of the shareware and encourages the user to register. The item numbers for “Register” and “Not Yet” item numbers must remain unchanged, but the rest of the dialog may be modified.

registerDLog is the id for the registration (and make registration) dialog. The “OK” and “Cancel” item numbers must remain unchanged, but the rest can be moved as long as the appropriate defines are changed. regPrintItem is the “Print” button and regMkPwdItem is the “Make Registration” button. The items from regFrstPritItem thru regLastPrtItem are printed when the “Print” button is selected. The regNameItem, the regNumberItem and the items from regFrstOtherSaveItem thru regLastOtherSaveItem are saved in the resource file in the resource type regDataResType.

regNumSeedValue is used by the ComputeRegistration routine as the seeded initial value.

longptr and longhan are two data types used, and the prototypes are the actual routines.

Now, lets look at all of the routines which comprise the registration module; they are in Register.c

The registration number is calculated from the name by ComputeRegistration.

Listing 3: ComputeRegistration

ComputeRegistration
long ComputeRegistration(Str255 name)
{
 long   regnum;
 short  i;

 if (StrLength(name) == 0) regnum = -1; 
 else regnum = regNumSeedValue;
 for (i = 1; i<= StrLength(name); i++) 
 regnum = regnum + name[i];
 return (regnum);
}

This computes a registration number for a name, by starting with a seed value, and adding the character code for each character of the name, in order. Although not unique, this allows for many variations by shareware authors. Some of the variations are to change the seed, different arithmetic on individual characters (twice the value, three times the value, alternately add and subtract...). Even these simple techniques can be quite hard to break for the average user, but only a brain teaser for the dedicated hacker.

After an application has started and initializes the Macintosh required managers, it only needs to call CheckRegistration to implement most of the registration functionality; the enhancements will be discussed later.

Listing 4: CheckRegistration

CheckRegistration
// CheckRegistration verifies the remembered name and registration number and asks // the user to register 
the software if the verification fails.

void CheckRegistration(void)
{
 StringHandle  namehan;
 longhanregwdhan;
 long   inregwdnum, computeregwdnum;


 namehan = 
 (StringHandle) GetResource(regDataResType, regNameItem);
 regwdhan = 
 (longhan) GetResource(regDataResType, regNumberItem);
 if ( (namehan != nil) && (regwdhan != nil) )
 {
 if ( 
 (GetHandleSize((Handle) namehan) > 1) &&                      
 (GetHandleSize((Handle) regwdhan) == 4) )
 {
 HLock( (Handle) namehan);
 HLock( (Handle) regwdhan);
 computeregwdnum = ComputeRegistration(*namehan);
 inregwdnum = **regwdhan;
 HUnlock( (Handle) namehan);
 HUnlock( (Handle) regwdhan);
 if ( namehan != nil) ReleaseResource( (Handle) namehan);
 if ( regwdhan != nil) ReleaseResource( (Handle) regwdhan);
 regwdhan = nil;
 namehan = nil;
 if ( inregwdnum != computeregwdnum) Register();
 }
 } else 
 {
 if ( namehan != nil ) ReleaseResource( (Handle) namehan);
 if ( regwdhan != nil ) ReleaseResource( (Handle) regwdhan);
 Register();
 }
}

CheckRegistration gets the remembered name and registration number from the regDataResType resource. If either is not there, then Register is called, otherwise a registration number is calculated from the remembered name and compared to the remembered registration number, and if they differ, then Register is called.

Listing 5: Register

Register
void Register(void)
{
 DialogPtrtheDialog;
 Handle theTextHdl;
 Rect itemBox;
 short  itemHit, theType, index;
 GrafPtrthePort;
 Str255 namestr, regstr;
 long regwordL;
 StringHandle  nameHan, strHan;
 longhanregsHan;


 FlushEvents (everyEvent, 0); /*throws out leftover events */
 if ( Alert(shareSplashAlert, nil) == OK )
 {
   FlushEvents (everyEvent, 0);
 theDialog = 
 GetNewDialog (registerDLog, nil, (WindowPtr) -1);
  if (theDialog != nil)
  {
   /*Hide the Make Reg Number button*/
   HideDialogItem(theDialog,regMkPwdItem);

   /*fill in text fields from save values*/
 strHan = 
 (StringHandle) GetResource(regDataResType, regNameItem);
 if ( strHan != nil) 
 {
 GetDialogItem (theDialog, regNameItem, &theType,              
 &theTextHdl, &itemBox);
   SetDialogItemText (theTextHdl, *strHan);
   ReleaseResource((Handle) strHan);
   }

 for ( index = regFrstOtherSaveItem; 
 index <= regLastOtherSaveItem; index ++)
 {
 strHan = (StringHandle) GetResource(regDataResType, index);
 if (strHan != nil)
 {
 GetDialogItem (theDialog, index, &theType, 
 &theTextHdl, &itemBox);
   SetDialogItemText (theTextHdl, *strHan);
   ReleaseResource((Handle) strHan);
  }
  }
   

  GetPort(&thePort);
 SetPort (theDialog);
  ShowWindow (theDialog); 
  do
  {
   ModalDialog (nil, &itemHit); 
   if ( itemHit == regPrintItem ) PrintRegForm(theDialog);     
  }while (itemHit > cancel);
   
  if ( (itemHit == ok) || (itemHit == regPrintItem) )
   {
   GetDialogItem (theDialog, regNameItem, &theType,            
 &theTextHdl, &itemBox);
   GetDialogItemText (theTextHdl, namestr);
   GetDialogItem (theDialog, regNumberItem, &theType,          
 &theTextHdl, &itemBox);
   GetDialogItemText (theTextHdl,regstr);
   StringToNum(regstr, &regwordL);
   if ( Length(namestr) > 0)
   {
 UnRegister();
 regsHan = (longhan) NewHandle(4);
   nameHan = NewString(namestr);
   **regsHan = regwordL;
   AddResource( (Handle) nameHan, regDataResType,              
 regNameItem , “\p”);
 if ( ResError() != noErr) 
 { itemHit = StopAlert(lockedAlert,nil);}
 WriteResource( (Handle) nameHan);
   AddResource( (Handle) regsHan,regDataResType,               
 regNumberItem , “\p”);
 if ( ResError() != noErr) 
 { itemHit = StopAlert(lockedAlert,nil); }
 WriteResource( (Handle) regsHan);
 UpdateResFile(CurResFile());
 for ( index = regFrstOtherSaveItem; 
 index <= regLastOtherSaveItem; index++)
 {
   GetDialogItem (theDialog, index, &theType,                  
 &theTextHdl, &itemBox);
   GetDialogItemText (theTextHdl,namestr);
   nameHan = NewString(namestr);
   AddResource( (Handle) nameHan,regDataResType, 
 index , “\p”);
 if ( ResError() != noErr) 
 { itemHit = StopAlert(lockedAlert,nil); }
 WriteResource( (Handle) nameHan);
 UpdateResFile(CurResFile());
 }
 }
   }    /*of ok || regPrintItem] */
   
  DisposeDialog(theDialog);
  SetPort(thePort);
 SetCursor(&qd.arrow);
   }
 }
}

Register puts up the information dialog (the shareSplashAlert), and if the user selects the “Register” button, it puts up the registration dialog, prints whenever the “Print” button is clicked, and exits when “OK” or “Cancel” is clicked. When “OK” is clicked, various entered data is remembered; the name, registration number, and fields from regFrstOtherSaveItem thru regLastOtherSaveItem. Register does not verify the registration number, but just remembers the data for the next invocation of the application.

To print the registration form, PrintRegForm is called.

Listing 6: PrintRegForm

PrintRegForm

void PrintRegForm(DialogPtr theDialog)
{ 
 short  index, which, xpos, ypos, theType;
 Handle theTextHdl;
 Rect   itemBox;
 GrafPtr  thePort;
 Str255 thestr, pbuf;
 TPPrPort PPort;
 THPrint  prh;
 Boolean  tmpb;
 TPrStatusstatus;
 Point  pos;
 
 if (regFrstPrtItem <= regLastPrtItem) /* ?something to print*/
 {
  GetPort(&thePort);
 prh = (THPrint) NewHandle(sizeof(TPrint));
 PrOpen();
 PrintDefault(prh);
 tmpb = PrValidate(prh);
 tmpb = PrStlDialog(prh);
 if (PrJobDialog(prh))
 {
 PPort = PrOpenDoc(prh,nil,nil);
 TextFont(times);
 TextSize(12);
 if (PrError() == noErr) PrOpenPage(PPort,nil);
  
  for ( index = regFrstPrtItem; 
 index <= regLastPrtItem; index++)
  {
  GetDialogItem (theDialog, index, &theType, 
 &theTextHdl, &itemBox);
  GetDialogItemText (theTextHdl, thestr);
  if ( StrLength(thestr) > 0)
  {
   xpos = itemBox.left;
   ypos = itemBox.top + 12;
   MoveTo(xpos,ypos);
   for ( which = 1; which <= StrLength(thestr); which++)
   {
   if ( thestr[which] < ‘ ‘)
   {
   ypos= ypos +12;
   MoveTo(xpos,ypos);
   } else DrawChar(thestr[which]);
   if ( thestr[which] == ‘ ‘)
   {
   GetPen(&pos);
   if ( pos.h >= itemBox.right)
   {  
   ypos= ypos +12;
   MoveTo(xpos,ypos);
   }
   }
   }
  }
  }
  if (PrError() == noErr)
  {
   PrClosePage(PPort);
 PrCloseDoc(PPort);
 if ( (**prh).prJob.bJDocLoop == bSpoolLoop)
 PrPicFile(prh,nil,nil,nil, &status);
 }
 PrClose();
 DisposeHandle((Handle) prh);
 SetPort(thePort);
 }
 } 
}

A routine to compute the registration number from the name is provided and uses the same dialog as the registration dialog, with an additional button “Make Registration.” Actually, the button is always present, but hidden by the Registration module. The user sends a printout from the Registration or sends the data electronically, you reenter the data, click “Make Registration,” click “Print” and return a copy with the registration number.

MakeRegistration is called via a pull down menu in the test program but in our actual products, it is called via special hidden commands, since we wanted only one product to maintain and required the ability to make a registration number from any copy of the product. Some possibilities are to install the make menu items as the result of selecting a standard pull down menu with various modifier keys depressed. A very complex mechanism can be constructed, which is easy to execute by the author but difficult to discover.

Listing 7: MakeRegistration

MakeRegistration

void MakeRegistration(void)
{
 DialogPtrtheDialog;
 Handle theTextHdl;
 Rect   itemBox;
 short  itemHit, theType;
 GrafPtrthePort;
 Str255 tmpstr;
 long   regwordL;


 FlushEvents (everyEvent, 0); /*throws out clicks, keys*/
 theDialog = GetNewDialog (registerDLog, nil, (WindowPtr) -1);
 if (theDialog != nil)
 { /*Shows the Make Password button*/
 ShowDialogItem(theDialog,regMkPwdItem);                       
 GetPort(&thePort);
 SetPort (theDialog);
 ShowWindow (theDialog);
 do
 {
 ModalDialog (nil, &itemHit); 
 if (itemHit == regMkPwdItem) /* make register # */
 {
 GetDialogItem (theDialog, regNameItem, &theType, 
 &theTextHdl, &itemBox);
 GetDialogItemText (theTextHdl,tmpstr);
 regwordL = ComputeRegistration(tmpstr);
 NumToString(regwordL,tmpstr);
 GetDialogItem (theDialog, regNumberItem, &theType,            
 &theTextHdl, &itemBox);
 SetDialogItemText (theTextHdl,tmpstr);
  } else 
 if (itemHit == regPrintItem)PrintRegForm(theDialog);
 }while (itemHit > cancel);
   
 DisposeDialog(theDialog);
 SetPort(thePort);
 SetCursor(&qd.arrow);
 }
}


It is advantageous for every shareware user to become an advocate of the product and distribute it widely, but only the unregistered version should be distributed. Thus, an unregistering module is provided and the user is encouraged to distribute the unregistered version to friends, bulletin boards, etc.

Every Macintosh application has an About... module, and we’ve added an unregister button to the About alert, as well as a place for the registered owners name.

Figure 4. The About... Alert

The changes in the About.. module are to retrieve the name from the resource file and display it. If “Unregister” is clicked on, then the unregister module is executed.

Listing 8: AboutApplication

AboutApplication

void AboutApplication(void)
{
 short tmpInt;
 StringHandle  regnameHan;

 regnameHan = (StringHandle)  GetResource(regDataResType,regNameItem);
 if ( regnameHan != nil)
 {
 HLock( (Handle) regnameHan);
 ParamText( *regnameHan, “\p”, “\p”, “\p”);
 HUnlock( (Handle) regnameHan);
 ReleaseResource( (Handle) regnameHan);
 } else ParamText( “\p”, “\p”, “\p”, “\p”);

 tmpInt = Alert(applicationAboutId, nil);
 if ( tmpInt == aboutUnregisterItem) UnRegister();
}

The UnRegister module deletes all of the user data; name, address... from the resources. This results in a version which reverts and asks for the shareware to be registered.

Listing 9: UnRegister

UnRegister
void UnRegister(void)
{
 Handle tmpHan;
 short  index;
 do
 {
 tmpHan = GetResource(regDataResType, regNameItem);
 if (tmpHan != nil)
 { 
 RemoveResource(tmpHan);
 DisposeHandle(tmpHan);
 UpdateResFile(CurResFile());
 }
 } while (tmpHan != nil);
 
 do
 {
 tmpHan = GetResource(regDataResType, regNumberItem);
 if (tmpHan != nil)
 { 
 RemoveResource(tmpHan);
 DisposeHandle(tmpHan);
 UpdateResFile(CurResFile());
 }
 } while (tmpHan != nil);

 for (index = regFrstOtherSaveItem; 
 index <= regLastOtherSaveItem; index++)
 do
 { 
 tmpHan = GetResource(regDataResType, index);
 if (tmpHan != nil)
 { 
 RemoveResource(tmpHan);
 DisposeHandle(tmpHan);
 UpdateResFile(CurResFile());
 }
 } while (tmpHan != nil);
}

Summary

Registration Tools provide a convenient package for generating a registration number based upon a name, gently encouraging the registration of the shareware, providing printed forms for ease of registration, and supporting the broad distribution of unregistered copies. These tools were written with the philosophy that shareware users will register for modest fees if the software performs desired functions, and they are tactfully reminded; we believe that the best way of evaluating shareware is to provide fully functioning software, with documentation.

Registration Tools does not provide copy protection, in fact the user is encouraged to UnRegister and distribute copies! In our examples, the registration is checked only at the beginning and the tests were built with symbol tables enabled; thus, it can be hacked quite easily with a debugger/disassembler. There are many improvements and variations to make “hacking” more difficult but most of us would prefer to get on with creating great shareware for the Macintosh!

We appreciate the excellent review by a MacTech reviewer, and the following is a quote from that review.

So that there is no misunderstanding, it should be made clear that neither the reviewer nor the magazine condone hacking as a way of avoiding payment to authors of commercial or shareware software. The point of this response is to point out to shareware authors the ease with which registration schemes can be bypassed, so that they are under no illusion about the security provided by these schemes. The Registration Tools approach is an effective way to remind users that a shareware fee needs to be paid, while allowing them the opportunity to try out all of the features of the software before deciding whether to purchase it, but it is not a copy protection scheme.

 

Community Search:
MacTech Search:

Software Updates via MacUpdate

Latest Forum Discussions

See All

Top Mobile Game Discounts
Every day, we pick out a curated list of the best mobile discounts on the App Store and post them here. This list won't be comprehensive, but it every game on it is recommended. Feel free to check out the coverage we did on them in the links... | Read more »
Price of Glory unleashes its 1.4 Alpha u...
As much as we all probably dislike Maths as a subject, we do have to hand it to geometry for giving us the good old Hexgrid, home of some of the best strategy games. One such example, Price of Glory, has dropped its 1.4 Alpha update, stocked full... | Read more »
The SLC 2025 kicks off this month to cro...
Ever since the Solo Leveling: Arise Championship 2025 was announced, I have been looking forward to it. The promotional clip they released a month or two back showed crowds going absolutely nuts for the previous competitions, so imagine the... | Read more »
Dive into some early Magicpunk fun as Cr...
Excellent news for fans of steampunk and magic; the Precursor Test for Magicpunk MMORPG Crystal of Atlan opens today. This rather fancy way of saying beta test will remain open until March 5th and is available for PC - boo - and Android devices -... | Read more »
Prepare to get your mind melted as Evang...
If you are a fan of sci-fi shooters and incredibly weird, mind-bending anime series, then you are in for a treat, as Goddess of Victory: Nikke is gearing up for its second collaboration with Evangelion. We were also treated to an upcoming... | Read more »
Square Enix gives with one hand and slap...
We have something of a mixed bag coming over from Square Enix HQ today. Two of their mobile games are revelling in life with new events keeping them alive, whilst another has been thrown onto the ever-growing discard pile Square is building. I... | Read more »
Let the world burn as you have some fest...
It is time to leave the world burning once again as you take a much-needed break from that whole “hero” lark and enjoy some celebrations in Genshin Impact. Version 5.4, Moonlight Amidst Dreams, will see you in Inazuma to attend the Mikawa Flower... | Read more »
Full Moon Over the Abyssal Sea lands on...
Aether Gazer has announced its latest major update, and it is one of the loveliest event names I have ever heard. Full Moon Over the Abyssal Sea is an amazing name, and it comes loaded with two side stories, a new S-grade Modifier, and some fancy... | Read more »
Open your own eatery for all the forest...
Very important question; when you read the title Zoo Restaurant, do you also immediately think of running a restaurant in which you cook Zoo animals as the course? I will just assume yes. Anyway, come June 23rd we will all be able to start up our... | Read more »
Crystal of Atlan opens registration for...
Nuverse was prominently featured in the last month for all the wrong reasons with the USA TikTok debacle, but now it is putting all that behind it and preparing for the Crystal of Atlan beta test. Taking place between February 18th and March 5th,... | Read more »

Price Scanner via MacPrices.net

AT&T is offering a 65% discount on the ne...
AT&T is offering the new iPhone 16e for up to 65% off their monthly finance fee with 36-months of service. No trade-in is required. Discount is applied via monthly bill credits over the 36 month... Read more
Use this code to get a free iPhone 13 at Visi...
For a limited time, use code SWEETDEAL to get a free 128GB iPhone 13 Visible, Verizon’s low-cost wireless cell service, Visible. Deal is valid when you purchase the Visible+ annual plan. Free... Read more
M4 Mac minis on sale for $50-$80 off MSRP at...
B&H Photo has M4 Mac minis in stock and on sale right now for $50 to $80 off Apple’s MSRP, each including free 1-2 day shipping to most US addresses: – M4 Mac mini (16GB/256GB): $549, $50 off... Read more
Buy an iPhone 16 at Boost Mobile and get one...
Boost Mobile, an MVNO using AT&T and T-Mobile’s networks, is offering one year of free Unlimited service with the purchase of any iPhone 16. Purchase the iPhone at standard MSRP, and then choose... Read more
Get an iPhone 15 for only $299 at Boost Mobil...
Boost Mobile, an MVNO using AT&T and T-Mobile’s networks, is offering the 128GB iPhone 15 for $299.99 including service with their Unlimited Premium plan (50GB of premium data, $60/month), or $20... Read more
Unreal Mobile is offering $100 off any new iP...
Unreal Mobile, an MVNO using AT&T and T-Mobile’s networks, is offering a $100 discount on any new iPhone with service. This includes new iPhone 16 models as well as iPhone 15, 14, 13, and SE... Read more
Apple drops prices on clearance iPhone 14 mod...
With today’s introduction of the new iPhone 16e, Apple has discontinued the iPhone 14, 14 Pro, and SE. In response, Apple has dropped prices on unlocked, Certified Refurbished, iPhone 14 models to a... Read more
B&H has 16-inch M4 Max MacBook Pros on sa...
B&H Photo is offering a $360-$410 discount on new 16-inch MacBook Pros with M4 Max CPUs right now. B&H offers free 1-2 day shipping to most US addresses: – 16″ M4 Max MacBook Pro (36GB/1TB/... Read more
Amazon is offering a $100 discount on the M4...
Amazon has the M4 Pro Mac mini discounted $100 off MSRP right now. Shipping is free. Their price is the lowest currently available for this popular mini: – Mac mini M4 Pro (24GB/512GB): $1299, $100... Read more
B&H continues to offer $150-$220 discount...
B&H Photo has 14-inch M4 MacBook Pros on sale for $150-$220 off MSRP. B&H offers free 1-2 day shipping to most US addresses: – 14″ M4 MacBook Pro (16GB/512GB): $1449, $150 off MSRP – 14″ M4... Read more

Jobs Board

All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.