SetFileInfo

InstallShield 2013 » InstallScript Language Reference

The SetFileInfo function sets the date or time stamp of an existing file or changes the file's attributes. To change both a file's date and time you must call SetFileInfo twice, once to change the date and once to change the time. However, you can set multiple file attributes with a single call to SetFileInfo by combining constants in nAttribute with the OR ( | ) operator.

Note: You can also use this function to change a folder's attribute. For example, you can use this function to create a hidden folder.

Syntax

SetFileInfo ( szPathFile, nType, nAttribute, szValue );

Parameters

SetFileInfo Parameters

Parameter

Description

szPathFile

Specifies the fully qualified name of the file or folder whose date, time, or attributes you want to change.

nType

Specifies the file characteristic to change. Pass one of the following predefined constants in this parameter:

FILE_ATTRIBUTE—Indicates that one or more of the file's attributes will be changed.
FILE_DATE—Indicates that the file's date stamp will be changed.
FILE_TIME—Indicates the file's time stamp will be changed.

nAttribute

Specifies the file attribute when nType is FILE_ATTRIBUTE. (When nType is FILE_DATE or FILE_TIME, pass 0 in this parameter.) To specify more than one file attribute, combine one or more of the following predefined constants with the OR (|) operator:

FILE_ATTR_ARCHIVED—Sets the archive attribute.
FILE_ATTR_HIDDEN—Sets the hidden attribute.
FILE_ATTR_READONLY—Sets the read-only attribute.
FILE_ATTR_SYSTEM—Sets the system attribute.
FILE_ATTR_NORMAL—When this constant is specified alone, all file attributes are cleared. When the OR operator is used to combine this constant with other file attribute constants, those attributes not included in the OR expression are cleared.

szValue

Specifies one of the following, depending on the value you passed in nType:

FILE_DATE—Specifies a date in the format YYYY/MM/DD or YYYY\MM\DD. That date must not be earlier than "1980/01/01". When using backslashes as delimiters, remember that a backslash is inserted into a string as an escape sequence, for example, "1980\\01\\01".
FILE_TIME—Specifies a time in the format HH:MM:SS, using a 24-hour clock format; note that the seconds must be a multiple of 2.
FILE_ATTRIBUTE—Pass a null string ("") in this parameter.

Return Values

SetFileInfo Return Values

Return Value

Description

0

Indicates that the function successfully set the file's date stamp, time stamp, or attributes.

< 0

Indicates that the function was unable to set the file's date stamp, time stamp, or attributes.

See Also