cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
jsvignesh
Level 2

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
Labels (1)
0 Kudos
(3) Replies
ericpaul
Level 6

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
    [LIST=1]
  • event: DoAction | argument: CheckLicense | condition: 1
  • event: EndDialog | argument: Exit | condition: not LICENSE_OK AND check for number of failures to enter a correct license code
  • event: NewDialog | argument: SetupType | condition: LICENSE_OK
  • event: SpawnDialog | argument: SomeDialog (indicating wrong license code) | condition: not LICENSE_OK



I hope this will also work for you.
0 Kudos
cwilliamsson
Level 3

Have same problem. Did you guys solve this?
0 Kudos