I have a TInputDirWizardPage to allow the user to pick a backup directory. It automatically allows and error checks the entered paths including UNC paths. The backup directory cannot be a UNC path. How can I make it not allow and error check UNC paths?
procedure InitializeWizard();
begin
BackupInfoPage :开发者_运维问答= CreateInputDirPage(100, 'caption', 'desc', 'sub caption', False,'Backup');
BackupInfoPage.Add('Backup Location:');
with BackupInfoPage do
begin
OnNextButtonClick := @BackupInfoForm_NextButtonClick;
end;
end;
function BackupInfoForm_NextButtonClick(Page: TWizardPage): Boolean;
begin
if not DirExists(BackupInfoPage.Values[0]) then
begin
ForceDirectories(BackupInfoPage.Values[0]);
end;
end;
I did this, but it didn't seem to do anything.
[Setup]
AllowUNCPath=false
So I added a check on the NextButtonClick to keep them on the enter path page until they enter a valid, non-unc path.
if (Copy(BackupLocale, 1, 2) = '\\') then
begin
MsgBox('UNC paths are not allowed.', mbError, MB_OK);
Result := False;
end;
精彩评论