0

I'm working on a c++ project using Visual Studio.

What I want to do is to include in my project two INI files.

I thought that, the fact that we simple add an existing item to the project would be the solution but it doesn't work. The INI thus is still not recognized by my project.

To be specific, what I want to do is to open/read the different files in my project.

How to do so?

M.Mellouli
  • 155
  • 1
  • 3
  • 10
  • What do you want to do exactly ? Edit them inside VS ? Or read/write in them with your program ? – JBL Jun 17 '13 at 07:48
  • Doesn't work how? That is exactly the way. – Balog Pal Jun 17 '13 at 07:49
  • @JBL I have edited my post. To be specific, what I want to do is to open/read the different files in my project. – M.Mellouli Jun 17 '13 at 07:50
  • What needs to open it? When? How? Can you show some code? Did you try just putting the files in the app directory? Does that work? Try "copy to output = always"? – sehe Jun 17 '13 at 07:50

2 Answers2

1

Well i guess the reason is that c++ has nothing to do with this file. A c++ project needs a .cpp file for your source code and maybe a header file .h to declare your functions // classes // whatever, but no ini file.

Look up for other types associated with a common c++ project on the microsoft page.

If you want to read from that file you don't have to include it in a VS project, but rather create a function to read from that file, see this example.

Community
  • 1
  • 1
fiscblog
  • 694
  • 1
  • 12
  • 27
0

I guess what you want is not simply include some files into the VS project/solution. What you want to do is parsing INI files.

You can use WINAPI functions to parse/write INI files, including WritePrivateProfileString, GetPrivateProfileString, GetPrivateProfileInt, etc.

You can also use some libraries, a good candidate should be INIH, a C and C++ library helps you parse ini files. But, it does not support write to the INI files.

Brent81
  • 1,152
  • 1
  • 13
  • 19