Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Read App.config values from MFC

Posted on 2010-09-03
10
Medium Priority
?
1,554 Views
Last Modified: 2012-05-10
Hi,

  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.

Thanks
0
Comment
Question by:Rajkumar Gs
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
  • +2
10 Comments
 
LVL 40

Expert Comment

by:evilrix
ID: 33595552
Since app.config is just XML of course you can read it... any XML library will cope just fine :)
0
 
LVL 23

Author Comment

by:Rajkumar Gs
ID: 33595593
Hi
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.

0
 
LVL 40

Expert Comment

by:evilrix
ID: 33595670
Like I said, just use any one of the plethora of XML libraries available for C/C++

http://www.xmlsoft.org/
http://xerces.apache.org/xerces-c/
http://www.grinninglizard.com/tinyxml/

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.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 33

Accepted Solution

by:
pgnatyuk earned 1500 total points
ID: 33595679
An add-on for the evilrix's comments:
CodeProject. Working with Configuration Files (app.config) in C++/CLI
http://www.codeproject.com/KB/mcpp/WorkingWithConfigFiles.aspx
0
 
LVL 23

Author Comment

by:Rajkumar Gs
ID: 33595759
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.

Thanks
0
 
LVL 33

Expert Comment

by:pgnatyuk
ID: 33596055
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++
http://msdn.microsoft.com/en-us/library/ms759192(VS.85).asp

IXMLDOMDocument is here:
http://msdn.microsoft.com/en-us/library/ms756987(VS.85).asp
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++
http://www.codeguru.com/cpp/misc/misc/article.php/c3707

You can find a code to download here:
CodeProject.C++ XML the easy way!
http://www.codeproject.com/KB/trace/C___XML_wrapper.aspx
0
 
LVL 22

Expert Comment

by:ambience
ID: 33603968
If you are in a hurry then use pure C++ based xml binder
http://www.codesynthesis.com/products/xsd/ 
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.
0
 
LVL 45

Expert Comment

by:AndyAinscow
ID: 33609115
Just a tiny point:
Is your app coded in .net (this is a .net area) or MFC.  They are NOT the same.
0
 
LVL 33

Expert Comment

by:pgnatyuk
ID: 33613458
CXMLParser added in MFC 10.
http://cppdepend.wordpress.com/2010/08/29/

BTW, Parsing XML using a C++ wrapper for SAX2
http://www.codeproject.com/KB/cpp/xml_support.aspx?display=Print
0
 
LVL 23

Author Closing Comment

by:Rajkumar Gs
ID: 33733200
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
Raj
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

596 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question