zoukankan      html  css  js  c++  java
  • WriteListBoxItems() ReadListBoxItems() IniFiles

     
    uses IniFiles;
     
     
    {写入列表框中的项目到ini中}
    //调用   WriteListBoxItems('settings.ini','Listbox',ListBox1);
    procedure WriteListBoxItems(const AINIFile, ASection: string; ListBox: TListBox);
    var
      INI: TINIFile;
      iniPath:string;//ini路径
      I: Integer;
    begin;
      iniPath:=ExtractFilePath(Application.ExeName)+AINIFile;
      INI := TINIFile.Create(iniPath);
      try
        INI.EraseSection(ASection);
        INI.WriteInteger(ASection, 'Count', ListBox.Items.Count);
        for I := 0 to ListBox.Items.Count - 1 do
        begin
          INI.WriteString(ASection, 'Item' + IntToStr(I), ListBox.Items[I]);
        end;
      finally
        INI.Free;
      end;
    end;



    {读取ini中的信息到列表框中中}
    //调用   ReadListBoxItems('settings.ini','Listbox',ListBox1);
    procedure ReadListBoxItems(const AINIFile, ASection: string; ListBox: TListBox);
    var
      INI: TINIFile;
      iniPath:string;
      I,count: Integer;
    begin
      iniPath:=ExtractFilePath(Application.ExeName)+AINIFile;
      INI := TINIFile.Create(iniPath);
      try
        ListBox.Clear;
        Count := INI.ReadInteger(ASection, 'Count', 0);
        for I := 0 to Count - 1 do
        begin
          ListBox.Items.Add(INI.ReadString(ASection, 'Item' + IntToStr(I), '0'));
        end;
      finally
        INI.Free;
      end;
    end;
     
     




    附件列表

    • 相关阅读:
      共享库的使用(.so)文件
      C/C++ 的宏中#和##的作用和展开
      有趣的打字训练
      libtool 创建库的工具
      vcpkg-微软开发的VC++打包工具
      Q他中的乱码再理解
      关于头文件和源文件的分别
      std::set 中内部元素有序条件删除的理解
      python 的 字节码 导入使用
      Pychar-20170301快捷键
    • 原文地址:https://www.cnblogs.com/xe2011/p/2609334.html
    Copyright © 2011-2022 走看看