PreviousNext
Macrovision

VerGetFileVersion Example

InstallShield 2008 ยป InstallScript Language Reference

Note

Note

To call this function in a Basic MSI setup, you must first create a custom action for the entry-point function, execute the custom action in a sequence or as the result of a dialog's control event, and then build the release.

/*--------------------------------------------------------------*\

*

* InstallShield Example Script

*

* Demonstrates the VerGetFileVersion function.

*

* The script below calls VerGetFileVersion to retrieve the

* version number of the Windows Notepad.  The information is

* displayed in a message box.

*

\*--------------------------------------------------------------*/

#define EXAMPLE_FILE WINDIR ^ "NotePad.exe"

#define TITLE_TEXT "VerGetFileVersion Example"

// Include Ifx.h for built-in InstallScript function prototypes.

#include "Ifx.h"

export prototype ExFn_VerGetFileVersion(HWND);

function ExFn_VerGetFileVersion(hMSI)

    NUMBER nResult;

    STRING szFile, szPath, szMsg, svVersionNumber;

begin

    // Get the version number of the specified file.

    nResult = VerGetFileVersion(EXAMPLE_FILE, svVersionNumber);

    // Report the results of VerGetFileVersion.

    if (nResult = FILE_NO_VERSION) then

        szMsg = EXAMPLE_FILE + " does not contain version information.";

        MessageBox (szMsg, INFORMATION);

    elseif (nResult = FILE_NOT_FOUND) then

        szMsg = EXAMPLE_FILE + " could not be found.";

        MessageBox (szMsg, INFORMATION);

    else

        szMsg    = "The version number of %s is %s";

        SprintfBox (INFORMATION, TITLE_TEXT, szMsg,

                   EXAMPLE_FILE, svVersionNumber);

    endif;

end;




Copyright Information | Contact Macrovision