Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Read through ini and combo box help

Status
Not open for further replies.

ErroR

Technical User
Apr 9, 2001
79
US
I'm trying to make a piece of code that will read an ini file which contains several values. I want it to work with a combo drop down box, so 1 line out of each section in the .ini will end up in the combo box as a choice, the other values in each section will be used as variables for other parts of the code, one of which specifies a file the client software needs.. maybe an example will make more sense:

[ServerName1]
Accounting Server 'common name for combo box
ClientFile.dat 'file copied for client
\accounting\dir1 'folder path for client

[ServerName2]
Payroll Server
ClientFile.dat
\payroll\dir1

etc etc etc

What's the best way to get the app to read into the ini file, match the section to the choice they made and then gather the variables it needs to make the decisions for the file, path, etc. I'm just not able to figure a clean way to do this part.

Any help is appreciated..
 
You should use the API calls:

GetPrivateProfileString
WritePrivateProfileString
for read/write from the INI (the declares you need you can find in the API viewer)

for that I suggest you wtite you sections like this(this is what I use in one game I made in VC++):

[ServerName1]
Key1=Accounting Server 'common name for combo box
Key2=ClientFile.dat 'file copied for client
Key3=\accounting\dir1 'folder path for client

[ServerName2]
Key1=Payroll Server
Key2=ClientFile.dat
Key3=\payroll\dir1

Then to fill the combo with the value you need you make a while...wend to the values you read from INI using the numbers 1,2,3 appended to the Key.

Hope this helps,s-)



Blessed is he who in the name of justice and good will, shepards the week through the valley of darknees...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top