I can't get my serial number validator to work. There is not enough detail in the help file.
The log says
Action 23:52:21: UserRegistrationDlg. Dialog created
Action start 23:52:27: AI_VALID_SERIAL.
Action ended 23:52:27: AI_VALID_SERIAL. Return value 3.
DEBUG: Error 2896: Executing action AI_VALID_SERIAL failed.
The installer has encountered an unexpected error installing this package. This may indicate a problem with this package. The error code is 2896. The arguments are: AI_VALID_SERIAL, ,
Action ended 23:52:27: WelcomeDlg. Return value 3.
my source code is this (please accept I know Java, not C++)
/* Replace "dll.h" with the name of your header */
#include "dll.h"
#include <windows.h>
#include "Msi.h"
#include "MsiDefs.h"
#include "MsiQuery.h"
#include <tchar.h>
#include <basetsd.h>
#include <stdlib.h>
#include <lm.h>
DllClass::DllClass()
{
}
DllClass::~DllClass ()
{
}
BOOL APIENTRY DllMain (HINSTANCE hInst /* Library instance handle. */ ,
DWORD reason /* Reason this function is being called. */ ,
LPVOID reserved /* Not used. */ )
{
switch (reason)
{
case DLL_PROCESS_ATTACH:
break;
case DLL_PROCESS_DETACH:
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
}
/* Returns TRUE on success, FALSE on failure */
return TRUE;
}
UINT __stdcall AI_VALID_SERIAL(MSIHANDLE hInstall)
{
MessageBox(0, _T("Validate"), _T("Message"), MB_ICONSTOP);
TCHAR szPidKey[8];
DWORD dwLen = sizeof(szPidKey)/sizeof(szPidKey[0]);
//retrive the text entered by the user
UINT res = MsiGetProperty(hInstall, _T("PIDKEY"), szPidKey, &dwLen);
MessageBox(0, _T(szPidKey), _T("Message"), MB_ICONSTOP);
if(res != ERROR_SUCCESS)
{
//fail the installation
return 1;
}
bool snIsValid = false;
//validate the text from szPidKey according to your algorithm
//put the result in snIsValid
TCHAR * serialValid;
if(snIsValid)
serialValid = _T("TRUE");
else
{
//eventually say something to the user
MessageBox(0, _T("Invalid Serial Number"), _T("Message"), MB_ICONSTOP);
serialValid = _T("FALSE");
}
res = MsiSetProperty(hInstall, _T("SERIAL_VALIDATION"), serialValid);
if(res != ERROR_SUCCESS)
{
return 1;
}
//the validation succeeded - even the serial is wrong
//if the SERIAL_VALIDATION was set to FALSE the installation
//will not continue
return 0;
}
Please explain what I must put in the dialog setup to make my dll work, and also explain why what I have is wrong.
Can you also supply a simple example of some code to validate the serial number.
FOLLOW US
Get the latest news in Application Packaging