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

Six fantastic ways to spend National Vid...
As if anyone needed an excuse to play games today, I am about to give you one: it is National Video Games Day. A day for us to play games, like we no doubt do every day. Let’s not look a gift horse in the mouth. Instead, feast your eyes on this... | Read more »
Old School RuneScape players turn out in...
The sheer leap in technological advancements in our lifetime has been mind-blowing. We went from Commodore 64s to VR glasses in what feels like a heartbeat, but more importantly, the internet. It can be a dark mess, but it also brought hundreds of... | Read more »
Today's Best 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 below... | Read more »
Nintendo and The Pokémon Company's...
Unless you have been living under a rock, you know that Nintendo has been locked in an epic battle with Pocketpair, creator of the obvious Pokémon rip-off Palworld. Nintendo often resorts to legal retaliation at the drop of a hat, but it seems this... | Read more »
Apple exclusive mobile games don’t make...
If you are a gamer on phones, no doubt you have been as distressed as I am on one huge sticking point: exclusivity. For years, Xbox and PlayStation have done battle, and before this was the Sega Genesis and the Nintendo NES. On console, it makes... | Read more »
Regionally exclusive events make no sens...
Last week, over on our sister site AppSpy, I babbled excitedly about the Pokémon GO Safari Days event. You can get nine Eevees with an explorer hat per day. Or, can you? Specifically, you, reader. Do you have the time or funds to possibly fly for... | Read more »
As Jon Bellamy defends his choice to can...
Back in March, Jagex announced the appointment of a new CEO, Jon Bellamy. Mr Bellamy then decided to almost immediately paint a huge target on his back by cancelling the Runescapes Pride event. This led to widespread condemnation about his perceived... | Read more »
Marvel Contest of Champions adds two mor...
When I saw the latest two Marvel Contest of Champions characters, I scoffed. Mr Knight and Silver Samurai, thought I, they are running out of good choices. Then I realised no, I was being far too cynical. This is one of the things that games do best... | Read more »
Grass is green, and water is wet: Pokémo...
It must be a day that ends in Y, because Pokémon Trading Card Game Pocket has kicked off its Zoroark Drop Event. Here you can get a promo version of another card, and look forward to the next Wonder Pick Event and the next Mass Outbreak that will be... | Read more »
Enter the Gungeon review
It took me a minute to get around to reviewing this game for a couple of very good reasons. The first is that Enter the Gungeon's style of roguelike bullet-hell action is teetering on the edge of being straight-up malicious, which made getting... | Read more »

Price Scanner via MacPrices.net

Take $150 off every Apple 11-inch M3 iPad Air
Amazon is offering a $150 discount on 11-inch M3 WiFi iPad Airs right now. Shipping is free: – 11″ 128GB M3 WiFi iPad Air: $449, $150 off – 11″ 256GB M3 WiFi iPad Air: $549, $150 off – 11″ 512GB M3... Read more
Apple iPad minis back on sale for $100 off MS...
Amazon is offering $100 discounts (up to 20% off) on Apple’s newest 2024 WiFi iPad minis, each with free shipping. These are the lowest prices available for new minis among the Apple retailers we... Read more
Apple’s 16-inch M4 Max MacBook Pros are on sa...
Amazon has 16-inch M4 Max MacBook Pros (Silver and Black colors) on sale for up to $410 off Apple’s MSRP right now. Shipping is free. Be sure to select Amazon as the seller, rather than a third-party... Read more
Red Pocket Mobile is offering a $150 rebate o...
Red Pocket Mobile has new Apple iPhone 17’s on sale for $150 off MSRP when you switch and open up a new line of service. Red Pocket Mobile is a nationwide MVNO using all the major wireless carrier... Read more
Switch to Verizon, and get any iPhone 16 for...
With yesterday’s introduction of the new iPhone 17 models, Verizon responded by running “on us” promos across much of the iPhone 16 lineup: iPhone 16 and 16 Plus show as $0/mo for 36 months with bill... Read more
Here is a summary of the new features in Appl...
Apple’s September 2025 event introduced major updates across its most popular product lines, focusing on health, performance, and design breakthroughs. The AirPods Pro 3 now feature best-in-class... Read more
Apple’s Smartphone Lineup Could Use A Touch o...
COMMENTARY – Whatever happened to the old adage, “less is more”? Apple’s smartphone lineup. — which is due for its annual refresh either this month or next (possibly at an Apple Event on September 9... Read more
Take $50 off every 11th-generation A16 WiFi i...
Amazon has Apple’s 11th-generation A16 WiFi iPads in stock on sale for $50 off MSRP right now. Shipping is free: – 11″ 11th-generation 128GB WiFi iPads: $299 $50 off MSRP – 11″ 11th-generation 256GB... Read more
Sunday Sale: 14-inch M4 MacBook Pros for up t...
Don’t pay full price! Amazon has Apple’s 14-inch M4 MacBook Pros (Silver and Black colors) on sale for up to $220 off MSRP right now. Shipping is free. Be sure to select Amazon as the seller, rather... Read more
Mac mini with M4 Pro CPU back on sale for $12...
B&H Photo has Apple’s Mac mini with the M4 Pro CPU back on sale for $1259, $140 off MSRP. B&H offers free 1-2 day shipping to most US addresses: – Mac mini M4 Pro CPU (24GB/512GB): $1259, $... Read more

Jobs Board

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