home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / PROG_GEN / REGKEY30.ZIP / C_CPP.ZIP / DEMOAPPD.CPP < prev    next >
C/C++ Source or Header  |  1994-03-07  |  2KB  |  65 lines

  1. // DemoAppD - C++ Language / DOS version of the RegKey demonstration program.
  2. //            Demonstrates the use of file-based registration key validation
  3. //            within a program using the RegKey system. Displays one of two
  4. //            simple messages based upon whether or not the user is
  5. //            registered. To test in registerd mode, use KeyGen to generate
  6. //            a *.KEY registration key file for DemoApp, and place that file
  7. //            in the current default directory. To test in unregistered mode
  8. //            remove any valid *.KEY files from the current default
  9. //            directory.
  10.  
  11.  
  12. #include <iostream.h>
  13.  
  14. #include "regkey.h"        // This must be included in any program using RegKey
  15.  
  16.  
  17. class CDemoApp            // Object to represent an instance of the application
  18.    {
  19. public:
  20.    void initialize(void);         // Application instance initialization method
  21.  
  22. private:
  23.    RKVALID RegisteredMode;                // Member to store mode to operate in
  24.    char RegistrationString[256];            // To store name of registered user
  25.    };
  26.  
  27.  
  28. main()
  29.    {
  30.    CDemoApp theApp;
  31.  
  32.    theApp.initialize();                   // Initalize the application instance
  33.  
  34.    return(0);
  35.    }
  36.  
  37.  
  38. void CDemoApp::initialize(void)          // Application instance initialization
  39.    {
  40.    // Check for a valid registration key file
  41.  
  42.    RegKeyFileValidate("*.KEY",             // Filespec of registration key file
  43.                       "0C9HMN1NDL",            // Application's validation code
  44.                       "Your Name", 0L,         // Your RegKey registration info
  45.                       RegistrationString,         // Where to place reg. string
  46.                       255,                       // Maximum size of reg. string
  47.         (RKVALID *)   &RegisteredMode);        // To store result of validation
  48.  
  49.  
  50.    if(RegisteredMode == RK_REGISTERED)
  51.       {
  52.       // If we are operating in registered mode, display registered message
  53.  
  54.       cout << "DemoApp is registered to: " << RegistrationString << "\n" ;
  55.       cout << "Thanks for registering DemoApp!\n" ;
  56.       }
  57.    else
  58.       {
  59.       // If operating in UNregistered mode, display UNregistered message
  60.  
  61.       cout << "DemoApp is NOT registered\n" ;
  62.       cout << "Please remember to register DemoApp!\n" ;
  63.       }
  64.    }
  65.