Read App.config values from MFC


  I have a doubt that Is it possible to read app.config values from MFC application.If it is possible could you please send the code or any useful links? It is very urgent i need.

LVL 23
Rajkumar GsSoftware EngineerAsked:
Who is Participating?
pgnatyukConnect With a Mentor Commented:
An add-on for the evilrix's comments:
CodeProject. Working with Configuration Files (app.config) in C++/CLI
evilrixSenior Software Engineer (Avast)Commented:
Since app.config is just XML of course you can read it... any XML library will cope just fine :)
Rajkumar GsSoftware EngineerAuthor Commented:
Thanks for your reply.
How can we read it? What is the code can we use? I know in .Net code to read app.config values. But i m new in MFC application. Hope your's reply.

Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

evilrixSenior Software Engineer (Avast)Commented:
Like I said, just use any one of the plethora of XML libraries available for C/C++

Anyone should do the job. Of those three Xerces is probably the best but also probably overkill for your simple needs. I'd probably consider libxml for what you are doing.

You could also code your own XML decoder... it's not (that) hard. I'd stick to a proven library thought.
Rajkumar GsSoftware EngineerAuthor Commented:
Hi pgnatyuk,
  This code i already done in visual c++ 2008 but in MFC it's something different.
so i am not expecting this one. Also i dont want to use third party tools. I need pure MFC application code to read values from app.config. Hope your's reply.

It cannot be pure MFC app. It can be pure Microsoft approach (or a kind of).
Take a look:
#import  raw_interfaces_only
using namespace MSXML2
It's not about MFC. It's more about COM.

MSDN. Program with DOM in C/C++

IXMLDOMDocument is here:
There is a simple code in the bottom.

In this article you will see more MFC-like samples:
Introduction to Using the XML DOM from Visual C++

You can find a code to download here:
CodeProject.C++ XML the easy way!
If you are in a hurry then use pure C++ based xml binder 
and grab App.config XSD files from say c:\Program Files (x86)\Microsoft Visual Studio 10.0\Xml\Schemas.
Those should be DotNetConfig.xsd and so on.
AndyAinscowFreelance programmer / ConsultantCommented:
Just a tiny point:
Is your app coded in .net (this is a .net area) or MFC.  They are NOT the same.
CXMLParser added in MFC 10.

BTW, Parsing XML using a C++ wrapper for SAX2
Rajkumar GsSoftware EngineerAuthor Commented:
Using this solution, I can achieve in a Windows Form Application. In MFC, I finally choosed INI file to get the data instead of app.config.

Thanks to all
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.