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

Retrieving variables from an INI file 1

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
How can I retrieve variables such as USERNAME from an INI file?
 
Assuming you know the section and tag name, it is very simple. For example, to read the following information

[My Section]
User Name=GLEASON

you just need to use the API noted by Keith Brautigam as follows (the third parameter is default data that will be copied into your buffer if the tag is not found or has no data after the = sign):

char IniBuf[16];
GetPrivateProfileString("My Section", "User Name", "DEFAULT", IniBuf, sizeof(IniBuf),"c:\myfile.ini");

Hope that helps!

Pat Gleason
gleason@megsinet.net

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top