如何将ini配置文件中的小节名在ListBox中显示出来?
解决方案 »
- Listview中单击它的Checkbox会触发什么事件
- 什么是 多步操作产生的错误!!!
- 下载了一个扩展名为IMG的xp安装文件,请问怎么用啊?
- 关于把DLL做成EXE文件,请大家帮我支招!!
- 请问:在delphi中如何将输入的单个字符转化成ASCII码?
- 重新开贴,老问题,以前的贴没考虑相等的情况!
- 本人想学delphi,不知各位觉得哪本书好一点
- 高手请进来
- 二个关于sql集与dbgrid的问题?
- 怎样实现EXCEL表格转换成ACCESS表
- 在打印机默认值中设好的纸型和方向,在QuickReport预览的打印机设置中,为什么方向被改变了?
- 求救:那位老兄有自己开发的医院信息管理系统HIS,能否卖给我啊。
StrList: TStringList;
i: integer;
Str: String;
begin
StrList := TStringList.Create;
for i := 0 to StrList.Count - 1 do
begin
Str := Trim(StrList.String[i]);
if Str[1] <> '[' then
ListBox1.items.add(Str);
end;
end;
回答的漂亮 佩服
上面有个问题哈,开始急着回答忽略了,呵呵StrList没释放
加上StrList.Free
var
strLine,stradd:string;
i,j:integer;
F: TextFile;
begin
try
AssignFile(F, 'c:\1.ini');
Reset(F);
except
Showmessage('err');
end; strLine := '';
while not eof(F) do begin
Readln(F, strLine);
if trim(strLine) = '' then begin
Continue;
end else begin
i:=pos('[',strline);j:=pos(']',strline); if (i> 0) and (j> 0) then begin
stradd:=copy(strline,i+1,j-i-1);
if stradd='' then continue;
listbox1.Items.Add(stradd); end
else continue; end;
end;
end;
调试通过,保证能用
var
Ini: TIniFile;
begin
Ini := TIniFile.Create('xxx.ini');
Ini.ReadSections(ListBox1.Items);
Ini.Free;
end;