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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

C++ and INI files anyone??

Status
Not open for further replies.

madhosh

Programmer
Aug 10, 2001
14
Thanks a lot for your help folks..
I need to access data in INI files using C++.Can anyone suggest some API's??
I used GetPrivateProfileString(..) but it returns only the value of the key name supplied.
How do I get values of all keys in a INI one by one?
 
Registry related Windows APIs are :
GetProfileInt, GetPrivateProfileInt
GetProfileSection, GetPrivateProfileSection
GetProfileString, GetPrivateProfileString
and so on...

You can use GetProfileSection to read the whole
of a profile section to a buffer, but you need to
find tokens in the buffer to get values you want to
get.

I think you can implement your routine by using
GetPrivateProfileString with 'for' loop. You wanted
"one by one" and 'for' loop will do "one by one".
Hee S. Chung
heesc@netian.com
 
In MFC you can:
WritePrivateProfileSection("MySection","","my.ini");
WritePrivateProfileString("MySection", "Name_autor", "Artem", "my.ini");
char lpReturnedString[100];
GetPrivateProfileString("MySection","Name_autor",
"not ready",lpReturnedString,99,"my.ini");

there are just samples of creating/writing/reading ini files. John Fill
1c.bmp


ivfmd@mail.md
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top