This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- Re: Serial number validation using c# DLL
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Nov 10, 2009
01:45 AM
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
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
(3) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Nov 11, 2009
05:35 AM
Facing the same challenge, we have
I hope this will also work for you.
- 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.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Apr 26, 2011
07:31 PM
Have same problem. Did you guys solve this?