Getcustomerkey.rul

                       
     
     
#define SD_DLG_CUSTOM_GET_CUSTOMER_KEY   "GetCustomerKey1"
#define SD_NDLG_CUSTOM_GET_CUSTOMER_KEY   22002
#define SD_EDIT_CUSTOMER_KEY         14
#define TITLE        50     
#define DESCRIPTION 51
prototype  GetCustomerKey( BYREF STRING, BYREF STRING,BYREF STRING,STRING,STRING );
prototype  SdCustomRegExEnableButton1( INT, INT,BYREF STRING);
prototype  SdCustomRegExValidatePassword1( BYREF STRING);

///////////////////////////////////////////////////////////////////////////////
//
//  FUNCTION: GetCustomerKey
//
//  PURPOSE:  This function displays a custom password dialog box.
//
///////////////////////////////////////////////////////////////////////////////
function  GetCustomerKey (szTitle,szMsg,svCustomerKey,pTitle,pDescription  )

        STRING  szDlg, szTemp;
        
        
        BOOL    bDone;
        NUMBER  nId, nMessage, nTemp, nSdDialog, nGetCustomerKey;
        HWND    hwndDlg, hwndControl;     
        

        begin

           szDlg     = SD_DLG_CUSTOM_GET_CUSTOMER_KEY;
           nSdDialog = SD_NDLG_CUSTOM_GET_CUSTOMER_KEY;

          // read data produced by this dialog if user runs setup in silent mode (Setup.exe -s)
          if (MODE = SILENTMODE) then
            SdMakeName( szAppKey, szDlg, szTitle, nGetCustomerKey );
                 
            SilentReadData( szAppKey, "Result", DATA_NUMBER, szTemp, nId );
            if ((nId != BACK) && (nId != CANCEL)) then
                SilentReadData( szAppKey, "svCustomerKey", DATA_STRING, svCustomerKey, nTemp );
            endif;

            return nId;
          endif;

           // ensure general initialization is complete
           if (!bSdInit) then
              SdInit( );
           endif;
           if (EzDefineDialog( szDlg, ISUSER, SD_DLG_CUSTOM_GET_CUSTOMER_KEY, 0 ) = DLG_ERR) then
               return -1;
           endif;

           // Loop in dialog until the user selects a standard button
           bDone = FALSE;

           while (!bDone)

              nId = WaitOnDialog( szDlg );

              switch(nId)
              case DLG_INIT:   
                

                   if( szMsg != "" ) then
                       SdSetStatic( szDlg, SD_STA_MSG, szMsg );
                   endif;
                   CtrlSetText( szDlg, SD_EDIT_CUSTOMER_KEY, svCustomerKey );
                   CtrlSetText( szDlg, TITLE, pTitle );
                   CtrlSetText( szDlg,DESCRIPTION , pDescription );
                   hwndDlg = CmdGetHwndDlg( szDlg );
                   SdGeneralInit( szDlg, hwndDlg, STYLE_BOLD, szSdProduct );
                   if(szTitle != "") then
                       SetWindowText(hwndDlg, szTitle);
                   endif;
                   SdCustomRegExEnableButton1( hwndDlg, NEXT,svCustomerKey);
              case SD_EDIT_CUSTOMER_KEY:
                   nMessage = CtrlGetSubCommand( szDlg );
                   if( nMessage = EDITBOX_CHANGE ) then
                       CtrlGetText( szDlg, SD_EDIT_CUSTOMER_KEY, svCustomerKey );
                   endif;

                   SdCustomRegExEnableButton1( hwndDlg, NEXT, svCustomerKey);

              case NEXT:
                   nId    = NEXT;
                   bDone  = TRUE;

              case BACK:
                   nId    = BACK;
                   bDone  = TRUE;

              case DLG_ERR:
                   SdError( -1, SD_DLG_CUSTOM_GET_CUSTOMER_KEY );
                   nId    = -1;
                   bDone  = TRUE;

              case DLG_CLOSE:
                   SdCloseDlg( hwndDlg, nId, bDone );

              default:
                   // check standard handling
                   if (SdIsStdButton( nId ) && SdDoStdButton( nId )) then
                       bDone = TRUE;
                   endif;
              endswitch;

           endwhile;

           EndDialog( szDlg );
           ReleaseDialog( szDlg );

           SdUnInit( );

           // record data produced by this dialog if user runs Setup.exe -r
           SdMakeName( szAppKey, szDlg, szTitle, nGetCustomerKey );
           SilentWriteData( szAppKey, "svCustomerKey", DATA_STRING, svCustomerKey, 0 );
           SilentWriteData( szAppKey, "Result",     DATA_NUMBER, "", nId );
           return nId;

       end;

 
///////////////////////////////////////////////////////////////////////////////
//
//  FUNCTION: SdCustomRegEnableButton
//
//  PURPOSE:  This function will enable or disable a certain button in
//            the GetCustomerKey dialog.
//
///////////////////////////////////////////////////////////////////////////////
function SdCustomRegExEnableButton1( hwndDlg, nControlID,svCustomerKey )
        HWND hwndItem;
        begin

           hwndItem = GetDlgItem( hwndDlg, nControlID );

           if (!IsWindow(hwndItem)) then return FALSE; endif;

           // trim trailing spaces from each field
          
           SdRemoveEndSpace( svCustomerKey );
           // if any of the fields are empty, disable the Next button
         //  if(svName = "" || svCompany = "" || svCustomerKey = "" || svSerial_2 = "" || svSerial_3 = "") then
              //EnableWindow( hwndItem, FALSE );
           //else
              ///////////////////////////////////////////////////////////////
              // Call Password Validation Code Here
              ///////////////////////////////////////////////////////////////
              if (SdCustomRegExValidatePassword1( svCustomerKey)) then
                      EnableWindow( hwndItem, TRUE);
              else
                      EnableWindow( hwndItem, FALSE);
              endif;
              ///////////////////////////////////////////////////////////////
              // End Password Validation
              ///////////////////////////////////////////////////////////////

          // endif;

        end;   
        
        

///////////////////////////////////////////////////////////////////////////////
//
// 	FUNCTION:  Validate Password
//
//  	 PURPOSE:  This function validates the serial number entered.
//
///////////////////////////////////////////////////////////////////////////////
function SdCustomRegExValidatePassword1( svCustomerKey)
    STRING svSub_svSerial_3;
    NUMBER nCalculation;
    begin
            if (StrLength(svCustomerKey)=StrLength("76260969-41FC-4607-82EC-9B7AC06BD434")) then
            	return TRUE;
            endif;    
       return FALSE;
    end;


In to Setup.rul you need write two function:

///////////////////////////////////////////////////////////////////////////////
//
// Function: CheckCustomerKey
//
//  Purpose: This function checks the registry, CD file called CustomerKey.txt
//           and then prompts user if not found.
//            

///////////////////////////////////////////////////////////////////////////////

function CheckCustomerKey()
	NUMBER nvType, nvSize, nFileHandle, nResult;      
	STRING szTitle, szMsg;   
	
begin

	RegDBSetDefaultRoot (HKEY_LOCAL_MACHINE);
	nvType = REGDB_STRING;
	
	// Check registry
	if StrCompare(CUSTOMER_KEY,"") = 0 then
		RegDBGetKeyValueEx(@LICENSE_BASE, "CustomerKey", nvType, CUSTOMER_KEY, nvSize);
	
		if StrLength(CUSTOMER_KEY) > 0 && StrLength(CUSTOMER_KEY) != 36 then
			MessageBox("The Customer Key in the registry was not 36 characters" , WARNING);
			CUSTOMER_KEY = "";
		elseif StrLength(CUSTOMER_KEY) == 36 then
			bByPassCustomerKey = TRUE;
		endif;
	
	
		// Check file
		if StrCompare(CUSTOMER_KEY,"") = 0 && Is(FILE_EXISTS, SRCDIR ^ "CustomerKey.txt") then
			OpenFileMode(FILE_MODE_BINARYREADONLY);
			OpenFile(nFileHandle, SRCDIR + "\\", "CustomerKey.txt");
			ReadBytes(nFileHandle, CUSTOMER_KEY, 0, 36);
			CloseFile(nFileHandle);

			if StrLength(CUSTOMER_KEY) != 36 then
				MessageBox("The Customer Key \"" + CUSTOMER_KEY + "\" in CustomerKey.txt on the CD was not 36 characters" , WARNING);
				CUSTOMER_KEY = "";
			else
				bByPassCustomerKey = TRUE;
			endif;
		endif;
	elseif StrLength(CUSTOMER_KEY) != 36 then
		CUSTOMER_KEY = "";
	endif;
	
	szTitle  = "";
  	szMsg    = "What is your Customer Key?\nIf you are not sure, please contact ACOM support.\nTel: (800)217-2266  Email: support@acom.com";
  	nResult=GetCustomerKey( szTitle,szMsg,CUSTOMER_KEY,"Customer Key Information","Please enter your Customer Key information.");
	if (nResult = BACK) then
			return BACK;
	endif;
	return NEXT;
end; 


///////////////////////////////////////////////////////////////////////////////
//
// Function: DialogShowSdWelcome
//
//  Purpose: This function handles the standard welcome dialog.
//
//
///////////////////////////////////////////////////////////////////////////////

function  DiablogInputCustomerKey()
	 NUMBER nResult;
     STRING   szField1, svEdit1; 
     NUMBER nType, nSize, nvType, nvSize;      
     STRING szKey, szNumName, szNumValue, svNumValue, szTitle, szMsg;      
     STRING szClass;  
     STRING  svName, svCompany;    
     STRING  svSerial_1, svSerial_2, svSerial_3;
begin
       szTitle  = "Customer Key";
	   szMsg    = "What is your Customer Key?\nIf you are not sure, please contact ACOM support.\nTel: (800)217-2266  Email: support@acom.com";
	   szField1 = "Your key:";
	   svEdit1  = "";
	   // Get a target folder name from the user.
	   szNumName  = "CustomerKey";
	   szNumValue = CUSTOMER_KEY;
	   nType      = REGDB_STRING;
	   nSize      = -1;                              
	   szKey = "SOFTWARE\\ACOM Solutions\\Licenses";
	     //key
	   //76260969-41FC-4607-82EC-9B7AC06BD434
	   // Huynh Chi: 76260969-41FC-4607-82EC-9B7AC06BD434
		//PhamXuan Dung: tks.
	    szTitle = "";
	    svSerial_1=   CUSTOMER_KEY;      
	    svEdit1=svSerial_1;
		CreateRegistryKey(szKey, szNumName, nType, svEdit1, nSize,FALSE)  ;
		szNumName="InstallPath";
		svEdit1=EZLICENSE ^"EZLicense.exe";
		CreateRegistryKey(szKey, szNumName, nType, svEdit1, nSize,FALSE)  ;
end;

After import Dialog “GetCustomerKey1.isd” into: User Interface->Dialog->All Dialogs. Notice rename file “getcustomerkey1-isd.doc” to “GetCustomerKey1.isd”.



Dowload

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: