InstallShield 2012 Spring » InstallScript Language Reference

Call the GetFileInfo function to determine a file's or directory's attributes, date, time, MD5 signature, or size. In each GetFileInfo statement, you can request only one of the data. For example, to obtain the date and time information for a file or directory, you must call GetFileInfo twice—once to obtain the date and once to obtain the time.


GetFileInfo ( szPathName, nType, nvResult, svResult );


GetFileInfo Parameters




Specifies the fully qualified name of the file or directory about which you want to retrieve information. You can specify a valid Uniform Resource Locator (URL) in this parameter unless you pass FILE_ATTRIBUTE or FILE_SHARED_COUNT as the nType parameter, in which case the function fails and returns ISERR_INVALID_ARG. To check the validity of a URL, call Is(VALID_PATH, szURL).


Specifies the type of file or directory information to retrieve. If the information is a number, GetFileInfo places it in nvResult. If the information is a string, GetFileInfo places it in svResult. Pass one of the following predefined constants in this parameter:

FILE_ATTRIBUTE—The attribute of the file or directory is returned in nvResult.
FILE_DATE—The date of the file or directory in the format YYYY\MM\DD is returned in svResult.
FILE_MD5_SIGNATURE—Returns the MD5 signature of the file specified in svResult. Generating and returning an MD5 signature is an expensive operation that requires reading the contents of the entire file. Only use this parameter when absolutely necessary. FILE_MD5_SIGNATURE is not supported for URLs.

Note: Raw MD5 signature data for a particular file consists of 16 generated numeric values of 16 bit each (between 0x00 abd 0xFF). These values are usually stored in a string of unsigned characters. However, the InstallScript language does not support unsigned characters, so instead of returning the raw MD5 file data, each of the 16 numeric values are converted to their string equivalent and placed in the resulting string. This results in a string of 32 characters, where each set of two characters represent a single numeric value. This is sometimes referred to as a MD5 hex string.

FILE_SHARED_COUNT—The file's reference count.
FILE_SIZE—The size in bytes is returned in nvResult (same as FILE_SIZE_LOW).
FILE_SIZE_LOW—The lower 31 bits of the file's size (in bytes) is returned in nvResult. If the size of the file is more than 2GB, the size of the file is equal to the value returned for FILE_SIZE_HIGH multiplied by 2GB added to the value returned for FILE_SIZE_LOW.
FILE_SIZE_HIGH—The upper 31 bits of the file's size (in bytes) is returned in nvResult. This value is 0 (zero) if the file is less than 2GB. If not, the size of the file is equal to the value returned for FILE_SIZE_HIGH multiplied by 2GB added to the value returned for FILE_SIZE_LOW.
FILE_TIME—The time of the file or directory in the format HH:MM:SS is returned in svResult.


Note: After calling GetFileInfo with FILE_ATTRIBUTE as the second parameter (nType), use if-then-else logic to determine the file's or directory's attributes. If nvResult = FILE_ATTR_NORMAL, then no attributes are set. If nvResult != FILE_ATTR_NORMAL, test the result of bitwise AND (&) operations on nvResult and one or more of the following file attribute constants to determine which attributes are set:

FILE_ATTR_NORMAL: The file is a normal file.
FILE_ATTR_ARCHIVED: The file is archived.
FILE_ATTR_DIRECTORY: The file is a directory.
FILE_ATTR_HIDDEN: The file is hidden.
FILE_ATTR_READONLY: The file is read-only.
FILE_ATTR_SYSTEM: The file is a system file.

    if (nvResult = FILE_ATTR_NORMAL) then

        //The file is NORMAL.


        if (FILE_ATTR_HIDDEN & nvResult) then

            //The file is HIDDEN.



        if (FILE_ATTR_READONLY & nvResult) then

          //The file is READ-ONLY.




Returns numeric information.


Returns string information.

Return Values

GetFileInfo Return Values

Return Value



Indicates that the function successfully retrieved the requested file information.


Indicates that an invalid argument was passed to the function.

All other negative values

Indicates that the function was unable to retrieve the requested information.

See Also