Results 1 to 4 of 4

Thread: Serial number validation using c# DLL

  1. #1
    Join Date
    Oct 2009
    Posts
    3

    Serial number validation using c# DLL

    Can anyone help me, how or what to set the next button (pushbutton) behavior on validating a c# dll for Serial Number Validation.

    I actually set DoAction, NewDialog and EndDialog Event for next button behavior. But I am not able to move to the next screen (dialog) from the customer information dialog on successful serial number.

    Following is my code in C#: -
    ====================
    public class ValidateSerialNumber
    {
    // Definition of Return Values:
    public const int SN_VALID_RETURN = 100; // Return Value Indicating Success
    public const int SN_INVALID_RETURN = 0; // Return Value Indicating Retry

    // Define Constant Used By ValidateSN()
    public const string CORRECT_SERIAL_NUM = "123456-78900"; // This is the Correct Serial Number

    public char SerialCheck(string sSerialNumber)
    {
    // Define Local Variables:
    int bValidResult; // Validation State of Serial Number

    bValidResult = ValidateSN(sSerialNumber);

    // Return Proper Value Based Upon Validation Routine
    if (bValidResult == 1)
    {
    // Serial Number is Valid: Inform Installshield Express to Continue
    return (char)SN_VALID_RETURN;
    }
    else
    {
    // Serial Number is Invalid: Inform Express to Retry
    MessageBox.Show( "Invalid Serial Number", "SERIAL NUMBER ERROR",MessageBoxButtons.OK, MessageBoxIcon.Exclamation );

    return (char)SN_INVALID_RETURN;
    }
    }

    private int ValidateSN(string sSerialNumber)
    {
    // Define Local Variables
    string sSNCheckString = string.Empty;
    //char sSNCheckString[20]; // String Used to Check Serial Number
    int iSNLen; // Length of Serial Number

    // Get Length of Serial Number
    iSNLen = sSerialNumber.Length;

    // Check if Serial Number is of Proper Length
    if ( iSNLen != 12 )
    {
    // Serial Number is NOT of Proper Length: Serial Number is Invalid
    return 0;
    }

    // Create Serial Number Check String
    //sprintf( sSNCheckString, "%s", CORRECT_SERIAL_NUM );
    sSNCheckString = CORRECT_SERIAL_NUM;

    // Check if Serial Number Matches the Check String
    if( string.Compare( sSNCheckString, sSerialNumber ) != 0 )
    //if ( strcmp( sSNCheckString, sSerialNumber ) != 0 )
    {
    // Serial Number Does NOT Match Check String: Serial Number is Invalid
    return 0;
    }

    // Serial Number is Valid
    return 1;
    }
    }

    Regards,
    Srivignesh Jaganathan

  2. #2
    Join Date
    May 2002
    Location
    The Netherlands
    Posts
    40
    Facing the same challenge, we have
    • created a DLL (C++) for checking the serial number
    • we call it in an InstallScript function and feed the value of the ISX_SERIALNUM property to it.
    • based on the result (0 or 1, just like your DLL) we set a custom property LICENSE_OK
    • we created a custom action CheckLicense for this function
    • in the Customer Information dialog's Next pushbutton behavior we have added several events
      1. event: DoAction | argument: CheckLicense | condition: 1
      2. event: EndDialog | argument: Exit | condition: not LICENSE_OK AND check for number of failures to enter a correct license code
      3. event: NewDialog | argument: SetupType | condition: LICENSE_OK
      4. event: SpawnDialog | argument: SomeDialog (indicating wrong license code) | condition: not LICENSE_OK


    I hope this will also work for you.

  3. #3
    Join Date
    Apr 2011
    Posts
    8
    Have same problem. Did you guys solve this?

  4. #4
    Join Date
    Mar 2004
    Posts
    30

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •