CheckFileAccess function
Check for the existence of the passed in files and test if the installer has write access to them. The variable LastExitCode is set to reflect the result of the test. See Remarks for ways to use this function.
The CheckFileAccess function is a predefined extension DLL function that is distributed with InstallMate. You can use this function by adding a Run DLL action to the action sequence in which you want to run the action. Set the Run DLL action attributes as follows:
- Function name: CheckFileAccess
- Arguments: "filepath" ["filepath"...]
Arguments
The CheckFileAccess function expects the following arguments. All arguments may contain symbolic references; these will be resolved before the function is called. Note that you must "quote" an argument if it contains spaces, or if it could contain spaces after expansion of symbolic references.
- filepath
- The fully qualified file path of the files that you want to test. The path may contain wildcards; in that case, all matching files are tested. You may enter more than one filepath argument; they will be tested from left to right and stop when the first error is encountered.
Return value
Returns ERROR_SUCCESS (zero) if successful, else a nonzero error code that indicates the first error that was encountered. This error code is available in the LastExitCode variable. See Remarks for ways to use this function and its result.
Remarks
The CheckFileAccess function can be used for various purposes, from simple file existence checks to file access and file-in-use checks. The function processes each filepath specification in turn, expanding wildcards as it goes. It stops when the first error is encountered; this is then returned in the LastExitCode variable. If all specified files exist and allow write access by the installer, the ERROR_SUCCESS (0) code is returned.
Typical error codes include the following:
Error code | Comments |
---|---|
ERROR_SUCCESS (0) | All specified files exist and allow write access by the installer. |
ERROR_FILE_NOT_FOUND (2) | One or more specified files do not exist, or a wildcard pattern does not match any file. |
ERROR_PATH_NOT_FOUND (3) | One or more folders implied by the file specifications do not exist. |
ERROR_ACCESS_DENIED (5) | One or more of the specified files do not allow write access by the installer, typically because of security settings on the file, its parent folder, or the network share through which the file is accessed. |
ERROR_SHARING_VIOLATION (32) | One or more of the specified files do not allow write access by the installer because some other process is using the file and does not allow modifications to it. |
other | Consult the Windows Platform SDK error code documentation. |
Here are some sample conditional expressions that you can use in actions after calling this function to test for specific cases.
Condition | Comments |
---|---|
LastExitCode | True if at least one specified file does not exist or does not allow write access. |
NOT LastExitCode | True if all specified files exist and allow write access. |
(LastExitCode = 2) OR (LastExitCode = 3) | True if at least one specified file does not exist. |
(LastExitCode = 5) OR (LastExitCode = 32) | True if at least one specified file does not allow write access. |
To use this function, you must add the extension DLL to your InstallMate project. The easiest way to do so is as follows:
- Open your InstallMate project.
- Choose File > Import > Project Items... from the main menu bar.
- Browse for and select the file Insert Extension DLL.imq, then click Open.
Alternatively, you can go to the Installer options page in your InstallMate project, click on the Advanced... button, then click on the Extension DLL tab and enter the paths to the extension DLL versions there.