⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 formaddmostunit.pas

📁 duiwenjiandechuli fangbianguanli.
💻 PAS
字号:
unit FormAddMostUnit;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls, IniFiles, Menus;

type
  TFormAddMost = class(TForm)
    pnlTop: TPanel;
    Image1: TImage;
    lbTitle: TLabel;
    Bevel1: TBevel;
    btnOk: TButton;
    btnCancel: TButton;
    lbTip: TLabel;
    cbxMostName: TComboBox;
    Bevel2: TBevel;
    Label1: TLabel;
    Label2: TLabel;
    MostName: TEdit;
    MostURL: TEdit;
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FormAddMost       : TFormAddMost;

procedure AddMostFormCreate;

implementation

uses PublicU, FormMainUnit;

{$R *.dfm}

procedure AddMostFormCreate;
var
  Count, Counter, MostCount, I: Integer;
  myPath            : string;
  myIni             : TIniFile;
  defSect           : string;
begin
  with TFormAddMost.Create(Application) do
  begin
    try
      if ShowModal = mrOk then
      begin
        defSect := cbxMostName.Text;
        if (defSect = '') or (defSect = '默认') then
          defSect := 'Public';

        if defSect <> '' then
        begin
          myPath := ExtractFilePath(ParamStr(0)) + 'Files\';
          if not DirectoryExists(myPath) then
            MkDir(myPath);
          myPath := myPath + 'Most.ini';

          MyIni := TIniFile.Create(myPath);
          try
            MostCount := MyIni.ReadInteger('MostIndex', 'Counter', 0);
            if not MyIni.SectionExists(defSect) then
            begin
              MyIni.WriteString('MostIndex', 'Name' + IntToStr(MostCount),
                defSect);
              MostCount := MostCount + 1;
              MyIni.WriteInteger('MostIndex', 'Counter', MostCount);
            end;

            Count := MyIni.ReadInteger(defSect, 'Counter', 0);
            Counter := Count;

            if not IniValExits(MyIni, defSect, MostURL.text) then
            begin
              MyIni.WriteInteger(defSect, 'Counter', Count + 1);
              MyIni.WriteString(defSect, 'Name' + IntToStr(Count),
                MostName.Text);
              MyIni.WriteString(defSect, 'Url' + IntToStr(Count),
                MostURL.text);
            end;
          finally
            MyIni.Free;
          end;
        end;
      end;
    finally
      Free;
    end;
  end;
end;

procedure TFormAddMost.FormCreate(Sender: TObject);
var
  I, Count          : Integer;
  MyIni             : TIniFile;
  myPath            : string;
begin
  Font := Screen.MenuFont;
  myPath := GetExePath + 'Files\Most.ini';
  if not FileExists(myPath) then
    Exit;

  MyIni := TIniFile.Create(myPath);
  try
    Count := MyIni.ReadInteger('MostIndex', 'Counter', 0);
    for I := 0 to Count - 1 do
      if MyIni.ReadString('MostIndex', 'Name' + IntToStr(I), '') <> 'Public'
        then
        cbxMostName.Items.Add(MyIni.ReadString('MostIndex', 'Name' +
          IntToStr(I),
          ''));
  finally
    MyIni.Free;
  end;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -