help~!

allanzong 2003-10-15 04:45:59
如何将ini配置文件中的小节名在ListBox中显示出来?
...全文
176 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
ruthfox 2003-10-19
  • 打赏
  • 举报
回复
方法很简单:
var
Ini: TIniFile;
begin
Ini := TIniFile.Create('xxx.ini');
Ini.ReadSections(ListBox1.Items);
Ini.Free;
end;
chw_csdn_chw 2003-10-17
  • 打赏
  • 举报
回复
procedure TForm1.Button1Click(Sender: TObject);
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;
调试通过,保证能用
pankun 2003-10-15
  • 打赏
  • 举报
回复
啊, angle097113兄言重了:)
上面有个问题哈,开始急着回答忽略了,呵呵StrList没释放
加上StrList.Free
angle097113 2003-10-15
  • 打赏
  • 举报
回复
pankun(剑神一笑)
回答的漂亮 佩服
pankun 2003-10-15
  • 打赏
  • 举报
回复
var
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;
gdwyh 2003-10-15
  • 打赏
  • 举报
回复
UP

5,379

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧