Question

I'm working on an Inno Setup installer that uses the GetOpenFileName function to bring up an open file dialog for the user to browse for and select a database file. The database will be running when the user selects the file but the installer is only trying to get the file's path as a string to configure our software.

On Windows XP this isn't a problem but I've noticed that on Windows 7 when selecting the running database file you get an error saying "This file is in use. Enter a new name or close the file that's open in another program."

Not sure if there is a way of disabling that error or another way of bringing up an open file dialog that isn't as restricted.

Thanks in advance.

Was it helpful?

Solution

If you're trying to get just the path, perhaps the BrowseForFolder function is a better choice. It displays a dialog box and allows the user to select a path.

From the documentation:

Prototype:
function BrowseForFolder(const Prompt: String; var Directory: String; const NewFolderButton: Boolean): Boolean;

Description:
Displays a dialog box that enables the user to select a directory. The current value of Directory is used as the initially selected directory. If NewFolderButton is True, a New Folder button will be shown, allowing the user to create new folders. Returns True if the user selected a directory and clicked OK, False otherwise. The selected directory is returned in the Directory string.

Remarks:
On Windows versions prior to XP, passing False in the NewFolderButton parameter has no effect; the New Folder button will always be shown. This is a Windows limitation.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top