Solved

Use Ini With ListBox1

Posted on 1998-12-01
1
236 Views
Last Modified: 2010-04-04
Hello!!!
I have a ini file and like to put all sections into listbox1
and under each section i like to add to listbox2
example of my ini
[SOFTSEEK]
URL=http://www.softseek.com
[DOWNLOAD.COM]
URL=http://www.download.com

E.g
I like to add [SOFTSEEK] into listbox1 and it's url to listbox2
URL=? into listbox2
Can i do this on event "OnCreate" of the form
Do you have a code..Thanks.....
0
Comment
Question by:mummi
1 Comment
 
LVL 3

Accepted Solution

by:
williams2 earned 50 total points
ID: 1348753
I think I've got it, try this

The INI file should look like this:
[URL0]
name=SOFTSEEK
URL=http://www.softseek.com
[URL1]
name=DOWNLOAD.COM
URL=http://www.download.com


The save it as 'urls.ini' in your project folder. Then the rest is cut'n'paste:

procedure TForm1.FormCreate(Sender: TObject);
var
  IniFile: TIniFile;
  i: Integer;
  Section,FName,FURL: String;
begin
  IniFile:= TIniFile.Create(ExtractFilePath(ParamStr(0))+'Urls.ini');
  i:= 0;
  Repeat
    Section:= 'URL'+IntToStr(i);
    FURL:= IniFile.ReadString(section,'URL','');
    FName:= IniFile.ReadString(section,'Name','');
    If FName<>'' then
    Begin
      ListBox1.Items.Add(FName);
      ListBox2.Items.Add(FURL);
    End;
    Inc(i);
  Until FName='';

end;

0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now