2
Reply

Setup validation

Astika Jadhav

Astika Jadhav

Feb 5 2011 3:23 AM
3.8k
firstly,the great thanks for nice help.
sir, Actually u gave  me the nice way for serial key validation.
But actually i am doing this first time and this is my first project i am not going to understand the some concepts in detail would u help me?.

i do my work according to the http://sudag.blogspot.com/2009/06/how-to-validate-serial-number-during.html this link suggested by u.
in this in comment 3 they are suggested to use the Validate a Serial Number During Installation of your Windows Installer (MSI) Using Orca this link so i do the as they suggested.
1.download
2.Install
3.click start then orca
4.open orca
then
I – Set up your VSI project

  1. Create an empty installer project with VSI.

  2. Add a Customer Information dialog box to the user interface. Do not change the default properties for the dialog box.

  3. Build the project.
II – Create a custom action DLL
      1.   Create
a custom action DLL that contains you serial number validation logic
             (I created the dll)
      2 . I use the same code that they suggested.but i got the errors at some lines so i comment the some line& my function is like:_
UINT __stdcall VerifyPID(MSIHANDLE hInstall)
{
        // Local variables
        UINT    nRetVal = 0;
        UINT    uiMsiRc;
        TCHAR   szPidKey[MAX_PATH];
        DWORD   dwBuffer;

        // First Step - Get the PIDKEY property
        //uiMsiRc = MsiGetProperty(hInstall, TEXT("PIDKEY"), szPidKey, &dwBuffer);

        if (ERROR_SUCCESS != uiMsiRc)
        {
//            MessageBox(NULL, "PIDKEY", "Not able to retrieve PIDKEY property", MB_OK  MB_ICONEXCLAMATION);
            return 0;
        }

        //Insert code to check PIDKEY here
//        int str = lstrcmp(szPidKey, "123 -4567890");

        int str;
        //If PIDKEY passes check
/*        if (str == 0)
//            MsiSetProperty(hInstall, "PIDCHECK", "TRUE");
        //If PIDKEY doesn't pass check
        else
        {
            MsiSetProperty(hInstall, "PIDCHECK", "FALSE");
            wsprintf(szText, "Please enter the correct code");
            MessageBox(NULL, szText, "PIDCHECK", MB_OK  MB_ICONINFORMATION);
        }*/

        return 0;
    }


Error    2    error C3861: 'MsiGetProperty': identifier not found    f:\astika\testdll\testdll.cpp 
   30    testdll is got at this line
uiMsiRc = MsiGetProperty(hInstall, TEXT("PIDKEY"), szPidKey, &dwBuffer);

Error    3    error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [7]' to 'LPCWSTR'    f:\astika\testdll\testdll.cpp    34    testdll
is got at each Messagebox
so can u resolve it.

Error    2    error C2664: 'lstrcmpW' : cannot convert parameter 2 from 'const char [13]' to 'LPCWSTR'    f:\astika\testdll\testdll.cpp    39    testdll
is got at line    int str = lstrcmp(szPidKey, "123 -4567890");

please help me.
i also the problems in 3,4,5 i can't understand what this steps means:
  1. On the Tools menu, click the Options Directories tab in your DLL project, and then add the path to the Windows Installer SDK's Include and Lib directories.

  2. In the Project Settings dialog box, add msi.lib to the library list.

  3. Then, either use a .DEF file or the __declspec(dllimport) attribute to export the DLL functions.

Answers (2)