Delphi 3.Библиотека программиста



              

Листинг 7 2 Процедура LoadSettings


procedure TfrmMain.LoadSettings; var Reg : TRegistry; Count : Integer; IPName : String; begin Reg := TRegistry.Create; // Чтение параметров try Reg.OpenKey(FtpServerKey, TRUE); if Reg.ValueExists('DRootDisk') then CsKeeper1.RootDisk := Reg.ReadString('DRootDisk') else CsKeeper1.RootDisk := ''; if Reg.ValueExists('DRootDir') then CsKeeper1.RootDir := Reg.ReadString('DRootDir') else CsKeeper1.RootDir := ''; finally Reg.CloseKey; end; try Reg.OpenKey(FtpServerKey, TRUE); if Reg.ValueExists('DTransferMode') then begin OldTransferMode := Reg.ReadString('DTransferMode'); if UpperCase(OldTransferMode) = UpperCase(FtpTransferStr[STREAM]) then begin CsKeeper1.Transfer := STREAM; rgTransfer.ItemIndex := 0; end; if UpperCase(OldTransferMode) = UpperCase(FtpTransferStr[BLOCK]) then begin CsKeeper1.Transfer := BLOCK; rgTransfer.ItemIndex := 1; end; if UpperCase(OldTransferMode) = UpperCase(FtpTransferStr[COMPRESSED]) then begin CsKeeper1.Transfer := COMPRESSED; rgTransfer.ItemIndex := 2; end; end else begin OldTransferMode := UpperCase(FtpTransferStr[STREAM]); CsKeeper1.Transfer := STREAM; end; finally Reg.CloseKey; end; // Свойство файловой структуры try Reg.OpenKey(FtpServerKey, TRUE); if Reg.ValueExists('DFileStructure') then begin OldFileStruct := Reg.ReadString('DFileStructure'); if UpperCase(OldFileStruct) = UpperCase(FtpFileStructStr[NOREC]) then begin CsKeeper1.FileStruct := NOREC; rgFileStructure.ItemIndex := 0; end; if UpperCase(OldFileStruct) = UpperCase(FtpFileStructStr[REC]) then begin CsKeeper1.FileStruct := REC; rgFileStructure.ItemIndex := 1; end; if UpperCase(OldFileStruct) = UpperCase(FtpFileStructStr[PAGE]) then begin CsKeeper1.FileStruct := PAGE; rgFileStructure.ItemIndex := 2; end; end else begin OldFileStruct := UpperCase(FtpFileStructStr[NOREC]); CsKeeper1.FileStruct := NOREC; rgFileStructure.ItemIndex := 0; end; finally Reg.CloseKey; end; // Разрешение на создание новых каталогов try Reg.OpenKey(FtpServerKey, TRUE); if Reg.ValueExists('DCreateNewDir') then begin OldMkDir := Reg.ReadBool('DCreateNewDir'); CsKeeper1.CreateDir := OldMkDir; if OldMkDir then cbAllowMkDir.State := cbChecked else cbAllowMkDir.State := cbUnChecked; end else begin OldMkDir := FALSE; CsKeeper1.CreateDir := OldMkDir; end; finally Reg.CloseKey; end; // Разрешение на удаление каталогов try Reg.OpenKey(FtpServerKey, TRUE); if Reg.ValueExists('DDeleteDir') then begin OldDeleteDir := Reg.ReadBool('DDeleteDir'); CsKeeper1.DeleteDir := OldDeleteDir; if OldDeleteDir then cbDeleteDir.State := cbChecked else cbDeleteDir.State := cbUnChecked; end else begin OldDeleteDir := FALSE; CsKeeper1.DeleteDir := OldDeleteDir; cbDeleteDir.State := cbUnChecked; end; finally Reg.CloseKey; end; // Разрешение на передачу файлов try Reg.OpenKey(FtpServerKey, TRUE); if Reg.ValueExists('DUpLoads') then begin OldUpLoads := Reg.ReadBool('DUpLoads'); CsKeeper1.UpLoads := OldUpLoads; if OldUpLoads then cbUpLoad.State := cbChecked else cbUpLoad.State := cbUnChecked; end else begin OldUpLoads := FALSE; CsKeeper1.UpLoads := OldUpLoads; cbUpLoad.State := cbUnChecked; end; finally Reg.CloseKey; end; try Reg.OpenKey(FtpServerKey, TRUE); if Reg.ValueExists('DNoBannedIPs') then NoOfBannedIPs := Reg.ReadInteger ('DNoBannedIPs') else NoOfBannedIPs := 1; finally Reg.CloseKey; end; // Список запрещенных IP-адресов for Count := 0 to NoOfBannedIPs - 1 do begin IPName := Concat('IPName', IntToStr(Count)); try Reg.OpenKey(FtpServerKey + '\IPs' + '\ ' + IPName, TRUE); if Reg.ValueExists('IPName') then lbBadIPAddrs.Items.Add(Reg.ReadString ('IPName')) else lbBadIPAddrs.Items.Add(''); OldBannedIPsList.Add(lbBadIPAddrs.Items.Strings [Count]); finally Reg.CloseKey; end; end; // цикл for with CsKeeper1 do begin if Length(RootDisk) > 0 then dcbRootDisk.Drive := Char(RootDisk[1]) else dcbRootDisk.Drive := 'C'; if Length(RootDir) > 0 then dlbRootDir.Directory := RootDir; for Count := 0 to NoOfBannedIPs - 1 do BadIPs.Add(lbBadIPAddrs.Items.Strings[Count]); end; Reg.Free; end;



Содержание Назад Вперед