a) Copy the files "RedRegImpl.cpp" and "RedRegImpl.h" to your project directory. These files are located in the directory "RedBaron Software\RedRegistration v3.0\Samples\vc5+" typically under your "Program Files" directory.
b) Add the files "RedRegImpl.cpp" and "RedRegImpl.h" to your project.
c) Open "VCRedReg.h", and add the following include lines before the class declarations:
#include "RedRegImpl.h" // RedRegistration MFC Wrapper Class
d) Declare CRedRegImpl as a base class of CVCRedRegApp. The declaration for CVCRedRegApp should be:
class CVCRedRegApp : public CWinApp, public CRedRegImpl
e) Add a member variable for the status of Registration. This variable will be used later to determine whether a nag screen should be displayed. Add the following code at the end of the class declaration for CVCRedRegApp:
private:
bool
m_bRegistered;
f) The next step is to initialize RedRegistration, first creating the object, and then initialize with your developer code. The function call InitRedReg handles this for you by calling the function InitRegistration with constants defined in the header file CRedRegImpl.h. The value returned by InitRegistration should be your checksum. This is verified to ensure that RedRegistration is active, and has not been compromised. Only if the value matches the code you received when registering will RedRegistration protect your software. If the value does not match, you should abort in your code. If the returned value is your checksum, as defined in the same header file, then the function will return TRUE.
Add the following code to the top of the InitInstance() function of CVCRedRegApp:
bool bRetVal;
bRetVal = InitRedReg();
if (
!bRetVal ) {
AfxMessageBox( _T("Initialization Failed.") );
return
FALSE;
}
g) Now that we have successfully registered RedRegistration with your developer code, it is time to retrieve the users registration. The method we use is LoadRegistration. This function assumes that a registration was previously saved using the method SaveRegistration. If LoadRegistration returns FALSE, then no registration exists, and the program should assume that we are in demo mode. If it returns TRUE, then we must verify the code is actually valid. A TRUE return from LoadRegistration only indicates that values where found, and that the properties UserName, CompanyName, RegCode, and Rights have been restored to their previous state. This does not indicate that the registration is valid, so the method Registered must be called.
The function CRedRegImpl::Registered() calls LoadRegistration() with the string defined in the header file CRedRegImpl.h. If the information is successfully loaded, then the function sets the Rights property to the value declared in the same header file.
Add the following code below the above code.
m_bRegistered = Registered();
AboutNag();