Wrox Programmer Forums
|
C++ Programming General discussions for the C++ language. For questions specific to Microsoft's Visual C++ variant, see the Visual C++ forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C++ Programming section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old January 2nd, 2006, 03:02 AM
Registered User
 
Join Date: Jan 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Reading .ini files

Hi All,
Any idea about how to read the actual content of a .ini file from a C++ program. Can we create an .ini file from a C++ program? Please help.
Thanks
Anisur

Reply With Quote
  #2 (permalink)  
Old February 5th, 2006, 09:06 PM
Registered User
 
Join Date: Feb 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to chandarnat Send a message via Yahoo to chandarnat
Default

In order to read a .INI file, you can use the GetPrivateProfileString API call. Refer to the following documentation.

http://msdn.microsoft.com/library/de...filestring.asp

You can use the WritePrivateProfileString to create or update an .INI file.

Hope this helps.

Reply With Quote
  #3 (permalink)  
Old February 7th, 2006, 05:02 PM
Registered User
 
Join Date: Feb 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to mikhailberis
Default

If you intend on reading the .ini file (or any particular file format for that matter) and using it in your program, yes there's a way. The "best" way is to use your platform's particular API methods (as mentioned above).

Another way is to use an existing parser implementation that already parses the .INI file contents -- this might involve using third party code, or some previously exported library that comes with your platform's compiler/toolset.

Another way still is to roll your own parser and generator to be able to deal with .INI files the way you want to. You might even want to make your own configuration file format, or even just use XML instead for your configuration needs.

Dean Michael C. Berris
Orange and Bronze Technologies, Inc.
Mobile +639287291459
Reply With Quote





Similar Threads
Thread Thread Starter Forum Replies Last Post
INI files Kis C# 3 April 2nd, 2015 05:04 AM
Reading an INI file in C# @shish C# 1 April 1st, 2015 04:00 AM
Reading ini file in XSL ROCXY XSLT 3 January 9th, 2007 04:37 AM
How to read and update .INI files using Pure C ?? Poonam C++ Programming 1 March 24th, 2005 01:22 AM
reading files nightsurfer JSP Basics 0 August 10th, 2003 04:34 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.