I am new to C++ and am using borland studio 2006 C++. I recently have been forced to take over the support for the C++ and have been given a number of complax C++ programs and these programs read and write to the registry. Now the problem comes in from the auditors side, because the programs as they are require administrator rights to read and write to the registry they have to be logged as aministrators and that according to the auditors is a security risk to the company. so i have been told to change this so that they no longer read/write to registry but to an ini file which can be stored in a directory.

Can anyone provide me with a link to how to create and read from ini files. any help you can provide will be most appreciated.

Thank you in advance


An INI file is just a file that you define. It's a text file containing the data you want to write to it. It's not a special file, it just has a different extension -- .INI

thats the problem. I do not know how to create and read from files. can you give me a link to where i can find a sample code or a tutorial?

this is all very confusing lol

Can anyone provide me with a link to how to create and read from ini files.

You might read up on the GetPrivateProfile...() and WritePrivateProfile...() functions, see Registry Functions

Just read up on how to open,read,write,close a file, as I posted. mitrmkar's suggestion is too high level for a beginner, and if you do it wrong, you could kill your computer.

i have read and am using this code but no file gets created , can anyone please help me:

[ TIniFile *StartUp = new TIniFile("privs.ini");

Left = StartUp->ReadInteger("FormPos", "Left", 250);
Top = StartUp->ReadInteger("FormPos", "Top", 200);

delete StartUp;

no file gets created

I've never used a Tinifile. From the syntax of the subsequent statements it seems like you're trying to read from it rather than write to it.

can you show me how to read and write to any type of file?

Take a look at the link I posted in my first reply. Try out some of the examples and then post back with any questions that you have. There's an overloaded << operator, so it's basically just opening the file and then using the operator like you would with cout.