gpt4 book ai didi

inno-setup - 如何限制目录编辑框的用户输入?

转载 作者:行者123 更新时间:2023-12-04 01:47:10 25 4
gpt4 key购买 nike

很难说出这里问的是什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或言辞激烈,无法以目前的形式合理回答。如需帮助澄清此问题以便可以重新打开,visit the help center .




9年前关闭。




我需要阻止用户进入 .在目录编辑框中输入的路径的末尾。

例如,路径不能是:

C:\Program Files\InnoSetup.

如何验证目录编辑框输入,或者如何防止用户输入 .到路径的尽头?

最佳答案

要自动删除目标目录末尾的所有点,您可以使用此脚本。你还没有回答我的问题,当在路径的尽头找到一个点时你想做什么,所以我选择了这样的方式出现。请注意,这将删除文件夹字符串末尾的所有点,因此从如下路径中删除:

C:\Program Files (x86)\My Program.....

这个脚本使得:
C:\Program Files (x86)\My Program

这是脚本:
[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program

[code]
procedure OnDirEditChange(Sender: TObject);
var
S: string;
begin
S := WizardDirValue;
if (Length(S) > 0) and (S[Length(S)] = '.') then
begin
MsgBox('Last char(s) of the entered target folder is "."' + #13#10 +
'All "." chars from the end will be deleted!', mbInformation, MB_OK);
while (Length(S) > 0) and (S[Length(S)] = '.') do
Delete(S, Length(S), 1);
WizardForm.DirEdit.Text := S;
end;
end;

procedure InitializeWizard;
begin
WizardForm.DirEdit.OnChange := @OnDirEditChange;
end;

procedure CurPageChanged(CurPageID: Integer);
begin
// this is just a paranoid event trigger, in case the DefaultDirName
// would be able to contain dots at the end, what can't at this time
if CurPageID = wpSelectDir then
OnDirEditChange(nil);
end;

当然还有另一种方法来验证路径,您可以例如让用户在最后输入带点的路径,并在您移至向导中的下一步时对其进行验证等。但是您只是没有指定如何编写验证问题的含义。

关于inno-setup - 如何限制目录编辑框的用户输入?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12931222/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com