home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / PROG_GEN / REGKEY30.ZIP / C_CPP.ZIP / REGKEY.H < prev    next >
C/C++ Source or Header  |  1994-03-07  |  10KB  |  194 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.                                                               C/C++ Header File
  19.  
  20.  
  21.  
  22.  
  23.           (C) Copyright Brian Pirie, 1993 - 1994. All Rights Reserved.
  24.  
  25. */
  26.  
  27. #ifndef REGKEY_H
  28. #define REGKEY_H
  29.  
  30.  
  31.  
  32. /* COMPILER-DEPENDANT DEFINITIONS */
  33. /* ------------------------------ */
  34. #ifdef __cplusplus
  35. #define RKFUNCDEF extern "C"
  36. #else
  37. #define RKFUNCDEF
  38. #endif
  39. #ifndef FAR
  40. #define FAR far
  41. #endif
  42.  
  43.  
  44.  
  45. /* FUNCTION RETURN VALUES */
  46. /* ---------------------- */
  47. typedef enum
  48.    {
  49.    RK_FAILURE,
  50.    RK_SUCCESS
  51.    } RKRETURN;
  52.  
  53.  
  54.  
  55. /* REGISTRATION KEY VALIDATION RESULTS */
  56. /* ----------------------------------- */
  57. typedef enum
  58.    {
  59.    RK_UNREGISTERED,
  60.    RK_REGISTERED
  61.    } RKVALID;
  62.  
  63.  
  64.  
  65. /* FUNCTION PROTOTYPES FOR THE REGKEY API */
  66. /* -------------------------------------- */
  67. #ifndef NOT_C_TARGET
  68.  
  69. /* RegKeyNewCodeSet()                                                        */
  70. /*                                                                           */
  71. /* Generates a registration key validation code corresponding to a           */
  72. /* generation code. This set of generation and validation codes is unique    */
  73. /* for each application using RegKey, and determines the unique registration */
  74. /* key that corresponds to a particular user's name. The secret generation   */
  75. /* code is used at registration key generation time, and the corresponding   */
  76. /* validation code is used within your application when validating a         */
  77. /* registration key. The validation and generation codes are each            */
  78. /* represented as a ten-digit strings of numbers and upper-case letters.     */
  79. /*                                                                           */
  80. /* This function is called by KeyGen or your own utility, and is only used   */
  81. /* once for each application using RegKey.                                   */
  82.  
  83. RKFUNCDEF RKRETURN RegKeyNewCodeSet(
  84.    const char FAR *szGenerationCode,   /* INPUT: Ten digit generation code   */
  85.    char FAR *szValidationCode);        /* OUTPUT: Ten digit validation code  */
  86.  
  87.  
  88. /* RegKeyGenerate()                                                          */
  89. /*                                                                           */
  90. /* Generates a registration key for a particular user, using the secret      */
  91. /* generation code corresponding to a particular application (as passed to   */
  92. /* RegKeyNewCodeSet()). The registration string is usually the name of the   */
  93. /* registered user, but may also contain other information, such as the      */
  94. /* version registered or date of expiry. The registration string may be zero */
  95. /* to 64K characters in length, and is null-terminated. The registration key */
  96. /* is returned as a string of letters and upper-case letters. The string     */
  97. /* pointed to by szRegKey must be large enough to hold 20 digits, plus a     */
  98. /* string terminator character. szRandomSeed should contain 10 random        */
  99. /* numbers and upper-case numbers, which are required during the             */
  100. /* registration key generation process.                                      */
  101. /*                                                                           */
  102. /* This function is called by KeyGen or your own registration key generation */
  103. /* utility, each time a registration key is generated for a new user. This   */
  104. /* function is used for user-entered registration keys; compare with         */
  105. /* RegKeyFileGenerate().                                                     */
  106.  
  107. RKFUNCDEF RKRETURN RegKeyGenerate(
  108.    const char FAR *szRegString,        /*  INPUT: Registration string        */
  109.    const char FAR *szGenerationCode,   /*  INPUT: App's generation code      */
  110.    const char FAR *szRandomSeed,       /*  INPUT: Random number seed         */
  111.    char FAR *szRegKey);                /* OUTPUT: 20-digit registration key  */
  112.  
  113.  
  114. /* RegKeyValidate()                                                          */
  115. /*                                                                           */
  116. /* Checks whether a given registration string and registration key           */
  117. /* combination is valid for a particular application, using the application- */
  118. /* specific validation code that was generated by RegKeyNewCodeSet(). The    */
  119. /* RKVALID pointed to by peRegistered is set to either RK_REGISTERED or      */
  120. /* RK_UNREGISTERED, indicating whether or not the registration key and       */
  121. /* registration string are valid. If you have registered RegKey, your own    */
  122. /* name and RegKey registration key should be passed to this function to     */
  123. /* disable the RegKey "unregistered" message.                                */
  124. /*                                                                           */
  125. /* This function is called from within your application each time it         */
  126. /* executes, in order to determine whether it should operate in registered   */
  127. /* or unregistered mode. This function is used with user-entered             */
  128. /* registration keys; compare with RegKeyFileValidate().                     */
  129.  
  130. RKFUNCDEF RKRETURN RegKeyValidate(
  131.    const char FAR *szRegString,        /*  INPUT: Registration string        */
  132.    const char FAR *szRegKey,           /*  INPUT: 20-digit registration key  */
  133.    const char FAR *szValidationCode,   /*  INPUT: App's validation code      */
  134.    const char FAR *szYourName,         /*  INPUT: Your name (if registered)  */
  135.    unsigned long int nYourKey,         /*  INPUT: Your key (if registered)   */
  136.    RKVALID FAR *peRegistered);         /* OUTPUT: Is key valid               */
  137.  
  138.  
  139. /* RegKeyFileGenerate()                                                      */
  140. /*                                                                           */
  141. /* Generates a file-based registration key for a particular user, using the  */
  142. /* secret generation code corresponding to a particular application (as      */
  143. /* passeed to RegKeyNewCodeSet()). The registration string is usually the    */
  144. /* name of the registered user, but may also contain other information, such */
  145. /* as the version registered or date of expiry. The registration string may  */
  146. /* be zero to 64K characters in length, and is null-terminated. A            */
  147. /* registration key file is generated, using the specified filename,         */
  148. /* containing the registration string and the resulting registration key.    */
  149. /* If a file with the specified name already exists, it is overwritten.      */
  150. /* szRandomSeed should contain 10 random numbers and upper-case letters,     */
  151. /* which are required during the registration key generation process.        */
  152. /*                                                                           */
  153. /* This function is called by KeyGen or your own registration key generation */
  154. /* utility, each time a registration key is generated for a new user. This   */
  155. /* function is used for file-based registration keys; compare with           */
  156. /* RegKeyGenerate().                                                         */
  157.  
  158. RKFUNCDEF RKRETURN RegKeyFileGenerate(
  159.    const char FAR *szRegString,        /*  INPUT: Registration string        */
  160.    const char FAR *szGenerationCode,   /*  INPUT: App's generation code      */
  161.    const char FAR *szRandomSeed,       /*  INPUT: Random number seed         */
  162.    const char FAR *szFileName);        /*  INPUT: Registration key file name */
  163.  
  164.  
  165. /* RegKeyFileValidate()                                                      */
  166. /*                                                                           */
  167. /* Checks whether the specified registration key file is valid for a         */
  168. /* particular application, using the application-specified validation code   */
  169. /* that was generated by RegKeyNewCodeSet(). The RKVALID pointed to by       */
  170. /* peRegistered is set to either RK_REGISTERED or RK_UNREGISTERED,           */
  171. /* indicating whether or not the registration key and registration string    */
  172. /* stored in the registration key file are valid. The szFileName parameter   */
  173. /* may include wildcards. If you have registered RegKey, your own name and   */
  174. /* RegKey registration key should be passed to this function to diable the   */
  175. /* RegKey "unregistered" message.                                            */
  176. /*                                                                           */
  177. /* This function is called from within your application each time it         */
  178. /* executes, in order to determine whether it should operate in registered   */
  179. /* or unregistered mode. This function is used with file-based registration  */
  180. /* keys; compare with RegKeyValidate().                                      */
  181.  
  182. RKFUNCDEF RKRETURN RegKeyFileValidate(
  183.    const char FAR *szFileName,         /*  INPUT: Registration key file name */
  184.    const char FAR *szValidationCode,   /*  INPUT: App's validation code      */
  185.    const char FAR *szYourName,         /*  INPUT: Your name (if registered)  */
  186.    unsigned long int nYourKey,         /*  INPUT: Your key (if registered)   */
  187.    char FAR *szRegString,              /* OUTPUT: Registration string        */
  188.    unsigned short int cbMaxStringSize, /*  INPUT: Size of reg. string        */
  189.    RKVALID FAR *peRegistered);         /* OUTPUT: Is key valid               */
  190.  
  191. #endif /* !defined(NOT_C_TARGET) */
  192.  
  193. #endif /* defined(REGKEY_H) */
  194.