Einzelnen Beitrag anzeigen

messie

Registriert seit: 2. Mär 2005
Ort: Göttingen
1.592 Beiträge
 
Delphi 2009 Professional
 
#2

Re: InstallShield Express Seriennummer über DLL

  Alt 29. Okt 2006, 12:30
Ich habe mir das Beispiel mal angesehen weil ich das auch noch nie probiert hatte. Ich konnte die dll erstellen und einbinden, bekam dann aber beim Ausführen "entry point not found".

Hier ist der BeispielCode der bei Installshield mitgeliefert wird:

Code:
// ValidateSN.cpp : Defines the entry point 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)
{
   //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;
   }
   else
      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;
Wenn jemand die Sache mit dem entry point erklären kann können wir das anschließend vielleicht ins Delphi übertragen.

Grüße, Messie
  Mit Zitat antworten Zitat