简体   繁体   English

正在使用的文件上的Inno Setup OpenFile对话框

[英]Inno Setup OpenFile dialog on a file that is in use

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. 我正在使用Inno安装程序安装程序,该安装程序使用GetOpenFileName函数来打开一个打开的文件对话框,供用户浏览并选择数据库文件。 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." 在Windows XP上,这不是问题,但是我注意到在Windows 7上,选择正在运行的数据库文件时,会出现错误消息:“此文件正在使用中。输入新名称或关闭在另一个程序中打开的文件。 ”

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. 提前致谢。

If you're trying to get just the path, perhaps the BrowseForFolder function is a better choice. 如果您只想获取路径,那么BrowseForFolder函数可能是一个更好的选择。 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.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM