home *** CD-ROM | disk | FTP | other *** search
/ Media Share 13 / mediashare_13.zip / mediashare_13 / ZIPPED / PROGRAM / REGKEY30.ZIP / VB.ZIP / REGKEYVB.BAS < prev    next >
BASIC Source File  |  1994-03-07  |  8KB  |  185 lines

  1. '
  2. '
  3. '
  4. '
  5. '
  6. '
  7. '                                                                   R E G K E Y
  8. '
  9. '------------------------------------------------------------------------------
  10. '
  11. '
  12. '                                                                  Version 3.00
  13. '
  14. '
  15. '                                   The Registration Key System For Programmers
  16. '
  17. '
  18. '                                            Visual Basic for Windows Interface
  19. '
  20. '
  21. '
  22. '
  23. '         (C) Copyright Brian Pirie, 1993 - 1994. All Rights Reserved.
  24. '
  25. '
  26.  
  27.  
  28.  
  29. ' FUNCTION RETURN VALUES
  30. ' ----------------------
  31.  
  32. Const RKFailure = 0
  33. Const RKSuccess = 1
  34.  
  35.  
  36.  
  37. ' REGISTRATION KEY VALIDATION RESULTS
  38. ' -----------------------------------
  39.  
  40. Const RKUnregistered = 0
  41. Const RKRegistered = 1
  42.  
  43.  
  44.  
  45. ' DLL FUNCTION DECLARATIONS
  46. ' -------------------------
  47.  
  48. Declare Function rkncs Lib "RK30VB.DLL" (ByVal sGenerationCode$, ByVal sValidationCode$) As Integer
  49. Declare Function rkg Lib "RK30VB.DLL" (ByVal sRegString$, ByVal sGenerationCode$, ByVal sRandomSeed$, ByVal sRegKey$) As Integer
  50. Declare Function rkv Lib "RK30VB.DLL" (ByVal sRegString$, ByVal sRegKey$, ByVal sValidationCode$, ByVal sYourName$, ByVal nYourKey As Long, peRegistered As Integer) As Integer
  51. Declare Function rkfg Lib "RK30VB.DLL" (ByVal sRegString$, ByVal sGenerationCode$, ByVal sRandomSeed$, ByVal sFileName$) As Integer
  52. Declare Function rkfv Lib "RK30VB.DLL" (ByVal sFileName$, ByVal sValidationCode$, ByVal sYourName$, ByVal nYourKey As Long, ByVal sRegString$, ByVal cbMaxStringSize As Integer, peRegistered As Integer) As Integer
  53.  
  54. Function RegKeyFileGenerate% (sRegString$, sGenerationCode$, sRandomSeed$, sFileName$)
  55. ' Generates a file-based registration key for a particular user, using the
  56. ' secret generation code corresponding to a particular application (as
  57. ' passeed to RegKeyNewCodeSet()). The registration string is usually the
  58. ' name of the registered user, but may also contain other information, such
  59. ' as the version registered or date of expiry. A registration key file is
  60. ' generated, using the specified filename, containing the registration string
  61. ' and the resulting registration key. If a file with the specified name
  62. ' already exists, it is overwritten. sRandomSeed should contain 10 random
  63. ' numbers and upper-case letters, which are required during the registration
  64. ' key generation process.
  65. '
  66. ' This function is called by KeyGen or your own registration key generation
  67. ' utility, each time a registration key is generated for a new user. This
  68. ' function is used for file-based registration keys; compare with
  69. ' RegKeyGenerate().
  70. '
  71. ' sRegString         INPUT: Registration string
  72. ' sGenerationCode    INPUT: App's generation code
  73. ' sRandomSeed        INPUT: Random number seed
  74. ' sFileName          INPUT: Registration key file name
  75.  
  76.     RegKeyFileGenerate% = rkfg(sRegString$, sGenerationCode$, sRandomSeed$, sFileName$)
  77.  
  78. End Function
  79.  
  80. Function RegKeyFileValidate% (sFileName$, sValidationCode$, sYourName$, nYourKey As Long, sRegString$, cbMaxStringSize As Integer, peRegistered As Integer)
  81. ' Checks whether the specified registration key file is valid for a
  82. ' particular application, using the application-specified validation code
  83. ' that was generated by RegKeyNewCodeSet(). The RKVALID pointed to by
  84. ' peRegistered is set to either RK_REGISTERED or RK_UNREGISTERED,
  85. ' indicating whether or not the registration key and registration string
  86. ' stored in the registration key file are valid. The sFileName parameter
  87. ' may include wildcards. If you have registered RegKey, your own name and
  88. ' RegKey registration key should be passed to this function to diable the
  89. ' RegKey "unregistered" message.
  90. '
  91. ' This function is called from within your application each time it
  92. ' executes, in order to determine whether it should operate in registered
  93. ' or unregistered mode. This function is used with file-based registration
  94. ' keys; compare with RegKeyValidate().
  95. '
  96. ' sFileName           INPUT: Registration key file name
  97. ' sValidationCode     INPUT: App's validation code
  98. ' sYourName           INPUT: Your name (if registered)
  99. ' nYourKey            INPUT: Your key (if registered)
  100. ' sRegString          OUTPUT: Registration string
  101. ' cbMaxStringSize     INPUT: Characters in reg. string
  102. ' peRegistered        OUTPUT: Is key valid
  103.  
  104.    sTemp$ = String$(cbMaxStringSize, 0)
  105.    RegKeyFileValidate% = rkfv(sFileName$, sValidationCode$, sYourName$, nYourKey, sTemp$, cbMaxStringSize + 1, peRegistered)
  106.    sRegString$ = sTemp$
  107.  
  108. End Function
  109.  
  110. Function RegKeyGenerate% (sRegString$, sGenerationCode$, sRandomSeed$, sRegKey$)
  111. ' Generates a registration key for a particular user, using the secret
  112. ' generation code corresponding to a particular application (as passed to
  113. ' RegKeyNewCodeSet()). The registration string is usually the name of the
  114. ' registered user, but may also contain other information, such as the
  115. ' version registered or date of expiry. The registration key is returned as a
  116. ' string of letters and upper-case numbers. sRegKey must be large enough to
  117. ' hold 20 digits. sRandomSeed should contain 10 random numbers and upper-case
  118. ' letters, which are required during the registration key generation process.
  119. '
  120. ' This function is called by KeyGen or your own registration key generation
  121. ' utility, each time a registration key is generated for a new user. This
  122. ' function is used for user-entered registration keys; compare with
  123. ' RegKeyFileGenerate().
  124. '
  125. ' sRegString          INPUT: Registration string
  126. ' sGenerationCode     INPUT: App's generation code
  127. ' sRandomSeed         INPUT: Random number seed
  128. ' sRegKey             OUTPUT: 20-digit registration key
  129.  
  130.    sTemp$ = String$(20, 0)
  131.    RegKeyGenerate% = rkg(sRegString$, sGenerationCode$, sRandomSeed$, sTemp$)
  132.    sRegKey$ = sTemp$
  133.  
  134. End Function
  135.  
  136. Function RegKeyNewCodeSet% (sGenerationCode$, sValidationCode$)
  137. ' Generates a registration key validation code corresponding to a
  138. ' generation code. This set of generation and validation codes is unique
  139. ' for each application using RegKey, and determines the unique registration
  140. ' key that corresponds to a particular user's name. The secret generation
  141. ' code is used at registration key generation time, and the corresponding
  142. ' validation code is used within your application when validating a
  143. ' registration key. The validation and generation codes are each
  144. ' represented as a ten-digit strings of numbers and upper-case letters.
  145. '
  146. ' This function is called by KeyGen or your own utility, and is only used
  147. ' once for each application using RegKey.
  148. '
  149. ' sGenerationCode     INPUT: Ten digit generation code
  150. ' sValidateCode       OUTPUT: Ten digit validation code
  151.  
  152.    sTemp$ = String$(10, 0)
  153.    RegKeyNewCodeSet% = rkncs(sGenerationCode$, sTemp$)
  154.    sValidationCode$ = sTemp$
  155.  
  156.  
  157. End Function
  158.  
  159. Function RegKeyValidate% (sRegString$, sRegKey$, sValidationCode$, sYourName$, nYourKey As Long, peRegistered As Integer)
  160. ' Checks whether a given registration string and registration key
  161. ' combination is valid for a particular application, using the application-
  162. ' specific validation code that was generated by RegKeyNewCodeSet(). The
  163. ' RKVALID pointed to by peRegistered is set to either RK_REGISTERED or
  164. ' RK_UNREGISTERED, indicating whether or not the registration key and
  165. ' registration string are valid. If you have registered RegKey, your own
  166. ' name and RegKey registration key should be passed to this function to
  167. ' disable the RegKey "unregistered" message.
  168. '
  169. ' This function is called from within your application each time it
  170. ' executes, in order to determine whether it should operate in registered
  171. ' or unregistered mode. This function is used with user-entered
  172. ' registration keys; compare with RegKeyFileValidate().
  173. '
  174. ' sRegString          INPUT: Registration string
  175. ' sRegKey             INPUT: 20-digit registration key
  176. ' sValidationCode     INPUT: App's validation code
  177. ' sYourName           INPUT: Your name (if registered)
  178. ' nYourKey            INPUT: Your key (if registered)
  179. ' peRegistered        OUTPUT: Is key valid
  180.  
  181.    RegKeyValidate% = rkv(sRegString$, sRegKey$, sValidationCode$, sYourName$, nYourKey, peRegistered)
  182.  
  183. End Function
  184.  
  185.