sfay
Posts: 12
Joined: Tue Jan 17, 2006 6:12 am
Location: Palm Harbor Florida

Creating A DLL file

How do you create a DLL file and where in the installer program is the file placed for a serial number registration.
FGump
Posts: 65
Joined: Thu Jan 05, 2006 7:23 pm

Serial number

I have not personally used the serial validation feature, however I hope this may help in your question. To create a DLL you must use a development language (compiler) such as MS C++ or Borland C++. The Advanced Installer has a small sample in their help file that shows some sample code and even allow for the download of sample code showing how to do this. Here is what is in the help file:

UINT __stdcall ValidateSerial_Sample(MSIHANDLE hInstall)
{
TCHAR szPidKey[PIDKEY_LENGTH];
DWORD dwLen = sizeof(szPidKey)/sizeof(szPidKey[0]);
//retrive the text entered by the user
UINT res = MsiGetProperty(hInstall, _T("PIDKEY"), szPidKey, &dwLen);
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
//willl not continue
return 0;
}

When you choose the DLL, it's included in your setup (there is no need to know where to put it). AI will use the DLL and the function you specify to validate the serial number. Hope this helps.

Regards,

FGump

Caphyon Support:
Can a COM DLL be used? It would be a nice feature to allow someone to use a COM DLL created by Visual Basic as not everyone is a C++ programmer.
sfay
Posts: 12
Joined: Tue Jan 17, 2006 6:12 am
Location: Palm Harbor Florida

Thanks

Thought that might be the process, still have to learn C++.
Alexander
Posts: 29
Joined: Thu Dec 30, 2004 12:47 pm
Location: Germany

Re: Thanks

sfay wrote:Thought that might be the process, still have to learn C++.
If you're looking for a easier programing language you may take a look at PureBasic.
I created my license dll with it, too.
kind regards,
Alex
Alexander
Posts: 29
Joined: Thu Dec 30, 2004 12:47 pm
Location: Germany

This would be the code for a PureBasic DLL:

Code: Select all

ProcedureDLL.l ValidateSerial_Sample(hInstall.l)
  
  #PIDKEY_LENGTH = 256
  szPidKey.s = Space(#PIDKEY_LENGTH)
  dwLen = #PIDKEY_LENGTH
  
  ;// retrive the text entered by the user
  res = MsiGetProperty_(hInstall, "PIDKEY", szPidKey, @dwLen)
  If res <> #ERROR_SUCCESS
    ;// fail the installation
    ProcedureReturn 1
  EndIf
  
  snIsValid = #False
  
  ;//validate the text from szPidKey according To your algorithm
  ;//put the result in snIsValid
  *serialValid.STRING

  If snIsValid
    *serialValid = @"TRUE"
  Else
    ;//eventually say something to the user
    MessageBox_(0, "Invalid Serial Number", "Message", #MB_ICONSTOP)
    *serialValid = @"FALSE"
  EndIf

  res = MsiSetProperty_(hInstall, "SERIAL_VALIDATION", *serialValid)

  If res <> #ERROR_SUCCESS
    ProcedureReturn 1
  EndIf

  ;//the validation succeeded - even the serial is wrong
  ;//If the SERIAL_VALIDATION was set To FALSE the installation
  ;//will not continue

  ProcedureReturn 0

EndProcedure
kind regards,
Alex

Return to “Common Problems”