FB II Compiler

PG PRO

Debugging

Memory

System

Mathematics

Resources

Disk I/O

Windows

Controls

Menus

Mouse

Keyboard

Text

Fonts

Drawing

Sound

Clipboard

Printing

Communication

ASM

Made with FB

FB II COMPILER

Put a serial number into a program



You place a serial number in the resources and check it every time the user runs the program, the code I used for a program follows (it's a bit much, but gives you the idea of how to do it and a couple of things more):

LOCAL FN checkWho
'---this routine checks for proper authorization (SPERLING, SEG, or AAPG)
'the resource string file (128) has 6 strings assigned to it.
'string 1 is the Key Name that is checked in the following SELECT code
'strings 2-4 are the remaining portions of the distributor's name
'(please keep in sequence)
'string 5 is the serial number (100 = Sperling, 101 = SEG, and 102 = AAPG)
'string 6 is the number of times the program has run
'(used on demo programs only)
'strings 1, 5 and 6 are required for program to run...

  who = 1 'SPERLING =1, SEG = 2, AAPG = 3
  er = 0
  SELECT CASE who
    CASE 1 'Sperling check
'the following code is designed to make the name 'SPERLING'
'remain in the resource file
'if someone changes Sperling (i.e., changes it to his name),
'then the program will note an error

      serialNo = 100 'serial number assigned to SPERLING
      a$ = STR# (128,1) 'get SPERLING from text resource
      b$ = LEFT$(a$,1) 'get 'S' --- should be 83
      c$ = RIGHT$(a$,1) 'get 'G' --- should be 71
      d$ = MID$(a$,3,1) 'get 'E' --- should be 69
      a = ASC (b$) + ASC (c$) + ASC(d$) - 1 'add them all together - 1
      IF a <> 222 THEN er = 1 'should equal 222

    CASE 2 'SEG check
'the following code is designed to make the name 'Society'
'remain in the resource file

      serialNo = 101 'serial number assigned to SEG
      a$ = STR# (128,1) 'get Society from text resource
      b$ = LEFT$(a$,1) 'get 'S' --- should be 83
      c$ = RIGHT$(a$,1) 'get 'y' --- should be 121
      d$ = MID$(a$,3,1) 'get 'c' --- should be 99
      a = ASC (b$) + ASC (c$) + ASC(d$) - 1 'add them all together -1
      IF a <> 302 THEN er = 1 'should equal 302

    CASE 3 'AAPG check
'the following code is designed to make the name
''American Association' remain in the resource file

      serialNo = 102 'serial number assigned to AAPG
      a$ = STR# (128,1) 'get American Association from text resource
      c$ = LEFT$(a$,1) 'get 'A' --- should be 65
      b$ = RIGHT$(a$,1) 'get 'n' --- should be 110
      d$ = MID$(a$,3,1) 'get 'e' --- should be 101
      a = ASC (b$) + ASC (c$) + ASC(d$) - 1 'add them all together -1
      IF a <> 275 THEN er = 1 'should equal 275

  END SELECT

  LONG IF er 'if er = 1 then someone has removed/altered the resource name
    Msg$ = "Error: This program has been altered... Restore original program and restart!"
    FN doError (Msg$) 'display error message

    END 'let's not work anymore...
  END IF

'the following code is designed to keep the registration
'number in the resocurces

  tmp$ = STR# (128,5) 'get the fifth string in resouce ID 128
  t = VAL(tmp$)
  LONG IF t <> serialNo 'registration number
    Msg$ = "Error: Registration Number has been removed"
    FN doError (Msg$) 'display error message

    END 'let's not work anymore...
  END IF

  LONG IF serialNo <> 100 '<<<---start of tempory use code
'the following code is designed to limit the amount of times
'that a person uses this software
'it works by altering a number in the internal resource file
'of the code by adding 1 to the number
'when a specific number is reached, then it notes an error and ends.
'this code would be removed from a purchased program

    tmp$ = STR# (128,6) 'sixth string in resource ID 128 (inital value = 1)
    t = VAL(tmp$) + 1 'add 1 to it
    tmp$ = STR$ (t) 'change it back to a string
    hndl& = FN GETRESOURCE (_"STR#",128) 'get the handle for the resource string
    LONG IF hndl& 'do we have a valid handle?
      DEF REMOVESTR (hndl&,6) 'remove and delete the original string (number 6)
      DEF APNDSTR (tmp$, hndl&) 'add and append a new string
      CALL CHANGEDRESOURCE (hndl&) 'tell the program of change (internal flag)
      CALL RELEASERESOURCE (hndl&) 'release the resource
    END IF

    LONG IF t > 50 'limit the number of program runs to 50
      a$ = STR$(serialNo)
      Msg$ = "Error: A" + a$ + " - Phone 517.393.1296"
      FN doError (Msg$) 'display error message

      END 'let's not work anymore...
    END IF

'the following code is designed to provide a limit to the time
'that a person can use this software. It works by checking the
'current data and comparing it to an internal data of 06/01/94
'if the current date is over that time period, then notes an
'error and ends...

    a$ = DATE$
    year$ = RIGHT$(a$,2)
    month$ = LEFT$(a$,2)
    year = VAL(year$)
    month = VAL(month$)

    LONG IF year > 93 AND month > 6
      a$ = STR$(serialNo)
      Msg$ = "Error: B" + a$ + " - Phone 517.393.1296"
      FN doError (Msg$) 'display error message

      END 'let's not work anymore...
    END IF
  END IF
END FN

Tedd