JohnSColeman
Posts: 7
Joined: Sun Mar 06, 2005 12:54 am

Serial number validator.

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.
John Coleman
Chat'n'Trade.com
JohnSColeman
Posts: 7
Joined: Sun Mar 06, 2005 12:54 am

PS

I cleaned up my class after finding some MSI notes on the web.

But I still get:

Error 1723. There is a problem with this Windows Installer package. A DLL required for this install to complete could not be run. Contact your support personnel or package vendor. Action AI_VALID_SERIAL, entry: UserReg, library: C:\DOCUME~1\John\LOCALS~1\Temp\MSIA6.tmp
Action ended 23:05:43: AI_VALID_SERIAL. Return value 3.

Is this a Windows/MSI issue? Any ideas of a fix?
John Coleman
Chat'n'Trade.com
Cata
Posts: 638
Joined: Thu Apr 10, 2003 7:37 am
Contact: Website

This is an issue with the DLL. And I can't tell which issue, as I'd need to look at the project file too...

We plan to have a set of comprehensive tutorials after the 2.5 release.

Cata
Catalin Rotaru - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
chantivlad
Posts: 7
Joined: Tue Mar 18, 2008 2:11 pm

example

Return to “Common Problems”