cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
luiscardona
Level 3

Serial Number Validation DLL.

Jump to solution

Hello, 

We try to load a DLL in Serial Number Validation DLL.

1. At the beginning we made this DLL in C# but we don't know why is not working in installshield.

2. We saw the example in installshield, this DLL is made it in C++ we compile this file in Visual Studio a we gave the path for this field in Serial Number validation. We build the solution, and we execute the setup file. This setup file load and in the credentials we put the serial number that is require to folow the next step, however when  the user click on next there is a popup window  (InstallShield DLL Custom Action) warning that said's:  File C:\Users\ADMIN~1.xxx\AppData\Local\Temp\2\_isA589.tmp' can not be found. Makse sure the file is on target system or installed already. We don't know what is wrong in the creation of the DLL or in the configuration.

3.There is a step by step tutorials or documentation that we can follow to configure this part of the serial numbers, instead of the basic help of installshield?

4.For the validation of the serial number is mandatory of create a DLL in C++? if don't, how can we load correctly the DLL o 

 

Labels (1)
0 Kudos
(2) Solutions

Hi @luiscardona,

Can you check the Dll(file *.tmp) is present in the path mentioned in the message box(in the attached screen shot)  before closing the message.

If it is present, then the problem might be with the dependency or in some cases the anti virus software delete the dll while extracting from the msi.

1- Check your Dll present in the path mentioned in the message box.

2- Check the dependency of your DLL, & the runtime configuration.

3- Verify how you are shipping the dll while creating the custom action, check it in Binary table

One more related thread related to the same kind of problem:

https://community.flexera.com/t5/InstallShield-Forum/DLL-Custom-Action-doesn-t-get-called-on-German-OS/td-p/89440 

 

View solution in original post

0 Kudos
And here is the link about /MD, /MT, /LD (Use Run-Time Library) in order to set the compiler option in the Visual Studio development environment: https://docs.microsoft.com/en-us/cpp/build/reference/md-mt-ld-use-run-time-library?view=vs-2019

View solution in original post

0 Kudos
(5) Replies

Hello @banna_k,

Thank you for the links.  We follow these instructions and does not work. Down below you can see the code that we have it in the sample DLL. Also we attached a screenshot of the error.

*******ValidateSN.cpp*******

// ValidateSN.cpp : Defines the exported functions for the DLL application.
//

#include "stdafx.h"
#include <tchar.h>
#include <stdlib.h>
#include "ValidateSN.h"

BOOL APIENTRY DllMain(HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}

LONG WINAPI ValidateSN(HWND hwnd, LPSTR szSrcDir, LPSTR szSupport, LPSTR szSerialNum, LPSTR szDbase)
{
try
{
//Copy serial number to temp variable before parsing
TCHAR szTemp[255];
_tcscpy(szTemp, szSerialNum);


//Get individual fields of the serial number (tokens separated by '-' chracter)
LPSTR szField1 = _tcstok(szTemp, TOKEN_SEPERATOR);
LPSTR szField2 = _tcstok(NULL, TOKEN_SEPERATOR);
LPSTR szField3 = _tcstok(NULL, TOKEN_SEPERATOR);

#ifdef _DEBUG //Display Debug information
CHAR szTmp[1024];
wsprintf(szTmp, "szSerialNum=%s. \nField #1=%s \nField #2=%s \nField #3=%s", szSerialNum, szField1, szField2, szField3);
MessageBox(GetFocus(), szTmp, "Serial Number Debug Window", MB_OK | MB_SYSTEMMODAL);
#endif

//Validate three fields in this example
if (ValidateField1(szField1) != VALIDATION_SUCCESS)
{
#ifdef _DEBUG //Display Debug information
MessageBox(GetFocus(), szField1, "Field #1 Validation Failed", MB_OK | MB_SYSTEMMODAL);
#endif

return VALDIATION_FAILED;
}
else if (ValidateField2(szField2) != VALIDATION_SUCCESS)
{
#ifdef _DEBUG //Display Debug information
MessageBox(GetFocus(), szField2, "Field #2 Validation Failed", MB_OK | MB_SYSTEMMODAL);
#endif

return VALDIATION_FAILED;
}
else if (ValidateField3(szField3) != VALIDATION_SUCCESS)
{
#ifdef _DEBUG //Display Debug information
MessageBox(GetFocus(), szField3, "Field #3 Validation Failed", MB_OK | MB_SYSTEMMODAL);
#endif

return VALDIATION_FAILED;
}
}
catch (...)
{
MessageBox(GetFocus(), "Serial number validation failed", "Failure", MB_OK | MB_SYSTEMMODAL);
return VALDIATION_FAILED;
}

return VALIDATION_SUCCESS;
}

LONG ValidateField1(LPSTR szField1)
{
//First field must be the string 'Field1'
if (0 == _tcsicmp(szField1, SERIALNUM_FIELD1))
return VALIDATION_SUCCESS;
else
return VALDIATION_FAILED;
}

LONG ValidateField2(LPSTR szField2)
{

long lNumToValidate = atoi(szField2);

//Second field must be a multiple of 5
if ((lNumToValidate % 5) == 0)
return VALIDATION_SUCCESS;
else
return VALDIATION_FAILED;
}

LONG ValidateField3(LPSTR szField3)
{
//Don't do anything - accept all values in third field
return VALIDATION_SUCCESS;

}

 

*******ValidateSN.h*******

//Constants
#define TOKEN_SEPERATOR _T("-")
#define SERIALNUM_FIELD1 _T("Field1")
#define VALIDATION_SUCCESS 1
#define VALDIATION_FAILED -1
#define SERIALNUMBER_LENGTH 22

//Function prototypes
LONG ValidateField1(LPSTR);
LONG ValidateField2(LPSTR);
LONG ValidateField3(LPSTR);

 

*******ValidateSN.def*******

LIBRARY "ValidateSN"

EXPORTS
ValidateSN @1

0 Kudos

Hi @luiscardona,

Can you check the Dll(file *.tmp) is present in the path mentioned in the message box(in the attached screen shot)  before closing the message.

If it is present, then the problem might be with the dependency or in some cases the anti virus software delete the dll while extracting from the msi.

1- Check your Dll present in the path mentioned in the message box.

2- Check the dependency of your DLL, & the runtime configuration.

3- Verify how you are shipping the dll while creating the custom action, check it in Binary table

One more related thread related to the same kind of problem:

https://community.flexera.com/t5/InstallShield-Forum/DLL-Custom-Action-doesn-t-get-called-on-German-OS/td-p/89440 

 

0 Kudos

Hello @banna_k 

Thank you for your help.

The link that you share we me has the solution in the last post:

"At last I could start my custom action!

The reason was obviously in the /MD "Runtime Library = Multi-Threaded DLL" switch of the DLL VS project.

After switch to the /MT "Runtime Library = Multi-Threaded" I could start all my custom actions including MFC DLL one.

So Josh was right from the very beginning. The missing dependency (C Runtime in this case I assume) was the problem.

Thanks for the help!"

https://community.flexera.com/t5/InstallShield-Forum/DLL-Custom-Action-doesn-t-get-called-on-German-OS/td-p/89440/page/2


Right now the example code is working correctly.

Thank you!

 

 

0 Kudos
And here is the link about /MD, /MT, /LD (Use Run-Time Library) in order to set the compiler option in the Visual Studio development environment: https://docs.microsoft.com/en-us/cpp/build/reference/md-mt-ld-use-run-time-library?view=vs-2019
0 Kudos